@openstax/ts-utils 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,16 +6,20 @@ export declare const isAppError: (e: any) => e is Error & {
6
6
  export declare class InvalidRequestError extends Error {
7
7
  static readonly TYPE = "InvalidRequestError";
8
8
  static matches: (e: any) => e is typeof InvalidRequestError;
9
+ constructor(message?: string);
9
10
  }
10
11
  export declare class UnauthorizedError extends Error {
11
12
  static readonly TYPE = "UnauthorizedError";
12
13
  static matches: (e: any) => e is typeof UnauthorizedError;
14
+ constructor(message?: string);
13
15
  }
14
16
  export declare class NotFoundError extends Error {
15
17
  static readonly TYPE = "NotFoundError";
16
18
  static matches: (e: any) => e is typeof NotFoundError;
19
+ constructor(message?: string);
17
20
  }
18
21
  export declare class SessionExpiredError extends Error {
19
22
  static readonly TYPE = "SessionExpiredError";
20
23
  static matches: (e: any) => e is typeof SessionExpiredError;
24
+ constructor(message?: string);
21
25
  }
@@ -19,21 +19,33 @@ const isAppError = (e) => e instanceof Error
19
19
  && typeof e.constructor.TYPE === 'string';
20
20
  exports.isAppError = isAppError;
21
21
  class InvalidRequestError extends Error {
22
+ constructor(message) {
23
+ super(message || InvalidRequestError.TYPE);
24
+ }
22
25
  }
23
26
  exports.InvalidRequestError = InvalidRequestError;
24
27
  InvalidRequestError.TYPE = 'InvalidRequestError';
25
28
  InvalidRequestError.matches = errorIsType(InvalidRequestError);
26
29
  class UnauthorizedError extends Error {
30
+ constructor(message) {
31
+ super(message || UnauthorizedError.TYPE);
32
+ }
27
33
  }
28
34
  exports.UnauthorizedError = UnauthorizedError;
29
35
  UnauthorizedError.TYPE = 'UnauthorizedError';
30
36
  UnauthorizedError.matches = errorIsType(UnauthorizedError);
31
37
  class NotFoundError extends Error {
38
+ constructor(message) {
39
+ super(message || NotFoundError.TYPE);
40
+ }
32
41
  }
33
42
  exports.NotFoundError = NotFoundError;
34
43
  NotFoundError.TYPE = 'NotFoundError';
35
44
  NotFoundError.matches = errorIsType(NotFoundError);
36
45
  class SessionExpiredError extends Error {
46
+ constructor(message) {
47
+ super(message || SessionExpiredError.TYPE);
48
+ }
37
49
  }
38
50
  exports.SessionExpiredError = SessionExpiredError;
39
51
  SessionExpiredError.TYPE = 'SessionExpiredError';
@@ -7,8 +7,8 @@ const logger_1 = require("../services/logger");
7
7
  const defaultHandlers = {
8
8
  UnauthorizedError: () => (0, routing_1.apiTextResponse)(401, '401 UnauthorizedError'),
9
9
  SessionExpiredError: () => (0, routing_1.apiTextResponse)(440, '440 SessionExpiredError'),
10
- NotFoundError: (e) => (0, routing_1.apiTextResponse)(404, e.message || '404 NotFoundError'),
11
- InvalidRequestError: (e) => (0, routing_1.apiTextResponse)(400, e.message || '400 InvalidRequestError'),
10
+ NotFoundError: (e) => (0, routing_1.apiTextResponse)(404, `404 ${e.message}`),
11
+ InvalidRequestError: (e) => (0, routing_1.apiTextResponse)(400, `400 ${e.message}`),
12
12
  };
13
13
  const createErrorHandler = (inputHandlers) => {
14
14
  const handlers = { ...defaultHandlers, ...inputHandlers };