|
| 1 | +abstract class OFREPApiError extends Error { |
| 2 | + constructor( |
| 3 | + public error: unknown | undefined, |
| 4 | + public response: Response | undefined, |
| 5 | + message?: string, |
| 6 | + options?: ErrorOptions, |
| 7 | + ) { |
| 8 | + super(message, options); |
| 9 | + Object.setPrototypeOf(this, OFREPApiError.prototype); |
| 10 | + this.name = OFREPApiError.name; |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +export class OFREPApiFetchError extends OFREPApiError { |
| 15 | + constructor(error: unknown, message?: string, options?: ErrorOptions) { |
| 16 | + super(error, undefined, message, options); |
| 17 | + Object.setPrototypeOf(this, OFREPApiFetchError.prototype); |
| 18 | + this.name = OFREPApiFetchError.name; |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +export class OFREPApiUnexpectedResponseError extends OFREPApiError { |
| 23 | + constructor(response?: Response, message?: string, options?: ErrorOptions) { |
| 24 | + super(undefined, response, message, options); |
| 25 | + Object.setPrototypeOf(this, OFREPApiUnexpectedResponseError.prototype); |
| 26 | + this.name = OFREPApiUnexpectedResponseError.name; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +export class OFREPApiUnauthorizedError extends OFREPApiError { |
| 31 | + constructor(response: Response, message?: string, options?: ErrorOptions) { |
| 32 | + super(undefined, response, message, options); |
| 33 | + Object.setPrototypeOf(this, OFREPApiUnauthorizedError.prototype); |
| 34 | + this.name = OFREPApiUnauthorizedError.name; |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +export class OFREPForbiddenError extends OFREPApiError { |
| 39 | + constructor(response: Response, message?: string, options?: ErrorOptions) { |
| 40 | + super(undefined, response, message, options); |
| 41 | + Object.setPrototypeOf(this, OFREPForbiddenError.prototype); |
| 42 | + this.name = OFREPForbiddenError.name; |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +export class OFREPApiTooManyRequestsError extends OFREPApiError { |
| 47 | + constructor(response: Response, message?: string, options?: ErrorOptions) { |
| 48 | + super(undefined, response, message, options); |
| 49 | + Object.setPrototypeOf(this, OFREPApiTooManyRequestsError.prototype); |
| 50 | + this.name = OFREPApiTooManyRequestsError.name; |
| 51 | + } |
| 52 | +} |
0 commit comments