src/caplinked-utils.js
function responseErrorBuilder(err, res) {
  if (res && res.body && _.isObject(res.body) && res.body.error) {
    // pass through error obj from API
    return res.body;
  } else {
    // build custom error
    return {
      error: {
        code: err.status || CL_CONSTANTS.RES_UNKNOWN,
        message: (res ? res.text : null) || err.toString(),
      }
    };
  }
}
function responseErrorBuilder(err, res) {
  if (res && res.body && _.isObject(res.body) && res.body.error) {
    // pass through error obj from API
    return res.body;
  } else {
    // build custom error
    return {
      error: {
        code: err.status || CL_CONSTANTS.RES_UNKNOWN,
        message: (res ? res.text : null) || err.toString(),
      }
    };
  }
}
function responseErrorBuilder ( err , res ) { if ( res && res . body && _ . isObject ( res . body ) && res . body . error ) { // pass through error obj from API return res . body ; } else { // build custom error return { error : { code : err . status || CL_CONSTANTS . RES_UNKNOWN , message : ( res ? res . text : null ) || err . toString ( ) , } } ; } }
Return an Error Object
Return an Error Object