diff --git a/src/error.ts b/src/error.ts index 6896ef6..81db881 100644 --- a/src/error.ts +++ b/src/error.ts @@ -5,6 +5,10 @@ export class FetchError extends Error { request?: FetchRequest response?: FetchResponse data?: T + status?: number + statusText?: string + statusCode?: number + statusMessage?: string } export function createFetchError (request: FetchRequest, error?: Error, response?: FetchResponse): FetchError { @@ -21,6 +25,10 @@ export function createFetchError (request: FetchRequest, error?: Error, Object.defineProperty(fetchError, 'request', { get () { return request } }) Object.defineProperty(fetchError, 'response', { get () { return response } }) Object.defineProperty(fetchError, 'data', { get () { return response && response._data } }) + Object.defineProperty(fetchError, 'status', { get () { return response && response.status } }) + Object.defineProperty(fetchError, 'statusText', { get () { return response && response.statusText } }) + Object.defineProperty(fetchError, 'statusCode', { get () { return response && response.status } }) + Object.defineProperty(fetchError, 'statusMessage', { get () { return response && response.statusText } }) return fetchError }