All files JSendError.js

50% Statements 4/8
100% Branches 0/0
25% Functions 1/4
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28        4x 4x 4x 4x                                        
import enhanceError from 'axios/lib/core/enhanceError';
 
class JSendError extends Error {
  constructor(message, { jsend, data, response }) {
    super(message);
    const { config, request } = response;
    const { toJSON, ...info } = enhanceError({}, config, null, request, response);
    Object.assign(this, info, {
      jsend,
      data,
      toJSON() {
        const json = toJSON.call(this);
        return Object.assign(json, { jsend, data });
      }
    });
  }
 
  get name() {
    return this.constructor.name;
  }
 
  get isJSendError() {
    return true;
  }
}
 
export default JSendError;