index.js
function detectErrors (err, responseSpec, next) {
      var callbackErr;
      if (err) {
        callbackErr = err;
      }
      else {
        var status = responseSpec.statusCode;
        if (status == 403) {
          callbackErr = new Charon.RequestForbiddenError(responseSpec);
        }
        else if (status == 404) {
          callbackErr = new Charon.ResourceNotFoundError(responseSpec);
        }
        else if (status == 409) {
          callbackErr = new Charon.ResourceConflictError(responseSpec);
        }
        else if (status >= 400 && status <= 499) {
          // 4xx error
          callbackErr = new Charon.ConsumerError(responseSpec);
        }
        else if (status >= 500 && status <= 599) {
          // 5xx error
          callbackErr = new Charon.ServiceError(responseSpec);
        }
        else if (! (status >= 200 && status <= 299)) {
          // not sure what this is, but it's not successful
          callbackErr = new Charon.RuntimeError('Unrecognized HTTP status code', responseSpec);
        }
      }
      this.invokeNext(callbackErr, responseSpec, next);
    }
function detectErrors (err, responseSpec, next) {
      var callbackErr;
      if (err) {
        callbackErr = err;
      }
      else {
        var status = responseSpec.statusCode;
        if (status == 403) {
          callbackErr = new Charon.RequestForbiddenError(responseSpec);
        }
        else if (status == 404) {
          callbackErr = new Charon.ResourceNotFoundError(responseSpec);
        }
        else if (status == 409) {
          callbackErr = new Charon.ResourceConflictError(responseSpec);
        }
        else if (status >= 400 && status <= 499) {
          // 4xx error
          callbackErr = new Charon.ConsumerError(responseSpec);
        }
        else if (status >= 500 && status <= 599) {
          // 5xx error
          callbackErr = new Charon.ServiceError(responseSpec);
        }
        else if (! (status >= 200 && status <= 299)) {
          // not sure what this is, but it's not successful
          callbackErr = new Charon.RuntimeError('Unrecognized HTTP status code', responseSpec);
        }
      }
      this.invokeNext(callbackErr, responseSpec, next);
    }
function detectErrors ( err , responseSpec , next ) { var callbackErr ; if ( err ) { callbackErr = err ; } else { var status = responseSpec . statusCode ; if ( status == 403 ) { callbackErr = new Charon . RequestForbiddenError ( responseSpec ) ; } else if ( status == 404 ) { callbackErr = new Charon . ResourceNotFoundError ( responseSpec ) ; } else if ( status == 409 ) { callbackErr = new Charon . ResourceConflictError ( responseSpec ) ; } else if ( status >= 400 && status <= 499 ) { // 4xx error callbackErr = new Charon . ConsumerError ( responseSpec ) ; } else if ( status >= 500 && status <= 599 ) { // 5xx error callbackErr = new Charon . ServiceError ( responseSpec ) ; } else if ( ! ( status >= 200 && status <= 299 ) ) { // not sure what this is, but it's not successful callbackErr = new Charon . RuntimeError ( 'Unrecognized HTTP status code' , responseSpec ) ; } } this . invokeNext ( callbackErr , responseSpec , next ) ; }
A response middleware function. Attempts to detect errors in the ``responseSpec`` and create appropriate error instances to pass to the ``next`` callback as necessary. This logic should be common for most APIs, but it may be overidden by the integrator if so desired.
A response middleware function . Attempts to detect errors in the responseSpec and create appropriate error instances to pass to the next callback as necessary . This logic should be common for most APIs but it may be overidden by the integrator if so desired .