diff --git a/package-lock.json b/package-lock.json index 9fa0091..2a70570 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@luckbox/http-adapter-factory", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9494ea3..4811de0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@luckbox/http-adapter-factory", - "version": "1.0.0", + "version": "1.0.1", "description": "Easy to use http adapter factory with support for GET/POST.", "author": "Luckbox", "main": "dist/index.js", diff --git a/src/GotHttpAdapter.ts b/src/GotHttpAdapter.ts index fb034b6..91b5138 100644 --- a/src/GotHttpAdapter.ts +++ b/src/GotHttpAdapter.ts @@ -122,6 +122,7 @@ class GotHttpAdapter implements HttpAdapter { throw new HttpStatusCodeError({ message: err.message, statusCode: err.response.statusCode, + body: err.response.body, }); } diff --git a/src/errors/HttpStatusCodeError.ts b/src/errors/HttpStatusCodeError.ts index 2300da1..68a6303 100644 --- a/src/errors/HttpStatusCodeError.ts +++ b/src/errors/HttpStatusCodeError.ts @@ -1,17 +1,20 @@ type ConstructorParams = { statusCode: number, message: string, + body: unknown, } class HttpStatusCodeError extends Error { public readonly statusCode: number; public readonly message: string; + public readonly body: unknown; constructor(params: ConstructorParams) { super(params.message); this.name = 'HttpStatusCodeError'; this.statusCode = params.statusCode; + this.body = params.body; } isTooManyRequests(): boolean {