log a little less about static meta headers
[squeep-api-dingus] / lib / errors.js
1 'use strict';
2
3 class DingusError extends Error {
4 constructor(...args) {
5 super(...args);
6 Error.captureStackTrace(DingusError);
7 }
8
9 get name() {
10 return this.constructor.name;
11 }
12 }
13
14 class ResponseError extends DingusError {
15 constructor(errorResponse, details) {
16 super(errorResponse.errorMessage);
17 Object.assign(this, {
18 ...errorResponse,
19 ...(details && { details }),
20 });
21 delete this.stack; // No need for stacktrace here.
22 }
23 }
24
25 class RouterError extends DingusError {
26 constructor(...args) {
27 super(...args);
28 delete this.stack;
29 }
30 }
31
32 class RouterNoPathError extends RouterError {
33 }
34
35 class RouterNoMethodError extends RouterError {
36 }
37
38 module.exports = {
39 DingusError,
40 ResponseError,
41 RouterError,
42 RouterNoPathError,
43 RouterNoMethodError,
44 };