errors.js 573 B

123456789101112131415
  1. export class HttpProxyMiddlewareError extends Error {
  2. code;
  3. constructor(message, code) {
  4. super(message);
  5. // add custom `code` property
  6. // so this can be used in src/plugins/default/error-response-plugin.ts to determine the status code to return
  7. this.code = code;
  8. // set the correct name for the error class
  9. this.name = this.constructor.name;
  10. // maintain proper stack trace (V8 environments)
  11. if (Error.captureStackTrace) {
  12. Error.captureStackTrace(this, this.constructor);
  13. }
  14. }
  15. }