| 25 | date?: string; |
| 26 | "request-id"?: string; |
| 27 | innerError?: ODataInnerError; |
| 28 | [key: string]: unknown; |
| 29 | } |
| 30 | |
| 31 | export class APIError< |
| 32 | TStatus extends number | undefined = number | undefined, |
| 33 | THeaders extends Headers | undefined = Headers | undefined, |
| 34 | TError extends ODataError | undefined = ODataError | undefined, |
| 35 | > extends Error { |
| 36 | /** HTTP status for the response that caused the error */ |
| 37 | readonly status: TStatus; |
| 38 | /** HTTP headers for the response that caused the error */ |
| 39 | readonly headers: THeaders; |
| 40 | /** JSON body of the response that caused the error */ |
| 41 | readonly error: TError; |
| 42 | |
| 43 | constructor( |
| 44 | status: TStatus, |
| 45 | error: TError, |
| 46 | message: string | undefined, |
| 47 | headers: THeaders, |
| 48 | ) { |
| 49 | super(`${APIError.makeMessage(status, error, message)}`); |
| 50 | this.status = status; |
| 51 | this.headers = headers; |
| 52 | this.error = error; |
| 53 | } |