www/category-category-module-es5.js
/**
     * Takes an HTTP response and returns the corresponding Error, if any.
     */
Takes an HTTP response and returns the corresponding Error, if any.
Takes an HTTP response and returns the corresponding Error if any .
function _errorForResponse(status, bodyJSON, serializer) {
      var code = codeForHTTPStatus(status); 
      var description = code;
      var details = undefined; 
      try {
        var errorJSON = bodyJSON && bodyJSON.error;
        if (errorJSON) {
          var status_1 = errorJSON.status;
          if (typeof status_1 === 'string') {
            if (!errorCodeMap[status_1]) {
              return new HttpsErrorImpl('internal', 'internal');
            }
            code = errorCodeMap[status_1]; 
            description = status_1;
          }
          var message = errorJSON.message;
          if (typeof message === 'string') {
            description = message;
          }
          details = errorJSON.details;
          if (details !== undefined) {
            details = serializer.decode(details);
          }
        }
      } catch (e) {
      }
      if (code === 'ok') {
        return null;
      }
      return new HttpsErrorImpl(code, description, details);
    }
function _errorForResponse ( status , bodyJSON , serializer ) { var code = codeForHTTPStatus ( status ) ; var description = code ; var details = undefined ; try { var errorJSON = bodyJSON && bodyJSON . error ; if ( errorJSON ) { var status_1 = errorJSON . status ; if ( typeof status_1 === 'string' ) { if ( ! errorCodeMap [ status_1 ] ) { return new HttpsErrorImpl ( 'internal' , 'internal' ) ; } code = errorCodeMap [ status_1 ] ; description = status_1 ; } var message = errorJSON . message ; if ( typeof message === 'string' ) { description = message ; } details = errorJSON . details ; if ( details !== undefined ) { details = serializer . decode ( details ) ; } } } catch ( e ) { } if ( code === 'ok' ) { return null ; } return new HttpsErrorImpl ( code , description , details ) ; }
Takes an HTTP response and returns the corresponding Error, if any.
Takes an HTTP response and returns the corresponding Error if any .
// Start with reasonable defaults from the status code. // Then look through the body for explicit details. // They must've included an unknown error code in the body. // TODO(klimt): Add better default descriptions for error enums. // The default description needs to be updated for the new code. // If we couldn't parse explicit error data, that's fine. // Technically, there's an edge case where a developer could explicitly // return an error code of OK, and we will treat it as success, but that // seems reasonable.