UNPKG

3.09 kBTypeScriptView Raw
1export interface FeathersErrorJSON {
2 readonly name: string;
3 readonly message: string;
4 readonly code: number;
5 readonly className: string;
6 readonly data?: any;
7 readonly errors: any;
8}
9
10export class FeathersError extends Error {
11 readonly code: number;
12 readonly className: string;
13 readonly data?: unknown;
14 readonly errors: any;
15 constructor (msg: string | Error, name: string, code: number, className: string, data: any);
16 toJSON (): FeathersErrorJSON;
17}
18
19export class BadRequest extends FeathersError {
20 constructor (msg?: string | Error, data?: any);
21}
22
23export class NotAuthenticated extends FeathersError {
24 constructor (msg?: string | Error, data?: any);
25}
26
27export class PaymentError extends FeathersError {
28 constructor (msg?: string | Error, data?: any);
29}
30
31export class Forbidden extends FeathersError {
32 constructor (msg?: string | Error, data?: any);
33}
34
35export class NotFound extends FeathersError {
36 constructor (msg?: string | Error, data?: any);
37}
38
39export class MethodNotAllowed extends FeathersError {
40 constructor (msg?: string | Error, data?: any);
41}
42
43export class NotAcceptable extends FeathersError {
44 constructor (msg?: string | Error, data?: any);
45}
46
47export class Timeout extends FeathersError {
48 constructor (msg?: string | Error, data?: any);
49}
50
51export class Conflict extends FeathersError {
52 constructor (msg?: string | Error, data?: any);
53}
54
55export class LengthRequired extends FeathersError {
56 constructor (msg?: string | Error, data?: any);
57}
58
59export class Unprocessable extends FeathersError {
60 constructor (msg?: string | Error, data?: any);
61}
62
63export class TooManyRequests extends FeathersError {
64 constructor (msg?: string | Error, data?: any);
65}
66
67export class GeneralError extends FeathersError {
68 constructor (msg?: string | Error, data?: any);
69}
70
71export class NotImplemented extends FeathersError {
72 constructor (msg?: string | Error, data?: any);
73}
74
75export class BadGateway extends FeathersError {
76 constructor (msg?: string | Error, data?: any);
77}
78
79export class Unavailable extends FeathersError {
80 constructor (msg?: string | Error, data?: any);
81}
82
83export interface Errors {
84 FeathersError: FeathersError;
85 BadRequest: BadRequest;
86 NotAuthenticated: NotAuthenticated;
87 PaymentError: PaymentError;
88 Forbidden: Forbidden;
89 NotFound: NotFound;
90 MethodNotAllowed: MethodNotAllowed;
91 NotAcceptable: NotAcceptable;
92 Timeout: Timeout;
93 Conflict: Conflict;
94 LengthRequired: LengthRequired;
95 Unprocessable: Unprocessable;
96 TooManyRequests: TooManyRequests;
97 GeneralError: GeneralError;
98 NotImplemented: NotImplemented;
99 BadGateway: BadGateway;
100 Unavailable: Unavailable;
101 400: BadRequest;
102 401: NotAuthenticated;
103 402: PaymentError;
104 403: Forbidden;
105 404: NotFound;
106 405: MethodNotAllowed;
107 406: NotAcceptable;
108 408: Timeout;
109 409: Conflict;
110 411: LengthRequired;
111 422: Unprocessable;
112 429: TooManyRequests;
113 500: GeneralError;
114 501: NotImplemented;
115 502: BadGateway;
116 503: Unavailable;
117}
118
119export function convert (error: any): FeathersError;
120
121export const types: Errors;
122export const errors: Errors;