diff --git a/package-lock.json b/package-lock.json index d236d65..693c992 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "objective-http", - "version": "2.1.3", + "version": "2.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "objective-http", - "version": "2.1.3", + "version": "2.1.4", "license": "LGPL-3.0-only", "devDependencies": { "@dotenvx/dotenvx": "^1.60.2", diff --git a/package.json b/package.json index 2bf4d3d..dece226 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "objective-http", - "version": "2.1.3", + "version": "2.1.4", "description": "Proxy classes for creating a http server", "keywords": [ "web", @@ -24,8 +24,8 @@ "test:coverage": "node scripts/coverage.js", "release": "release-it --config release-it.config.mjs", "release:no-increment": "release-it --ci --config release-it.config.mjs --no-increment --no-git", - "dist:build": "webpack --config webpack.config.mjs", - "dist:cleanup": "node scripts/cleanup.js" + "build": "webpack --config webpack.config.mjs", + "build:cleanup": "node scripts/cleanup.js" }, "publishConfig": { "access": "public" diff --git a/release-it.config.mjs b/release-it.config.mjs index bb11bc9..c739d65 100644 --- a/release-it.config.mjs +++ b/release-it.config.mjs @@ -25,11 +25,11 @@ export default { }, hooks: { 'before:init': [ - 'npm run dist:cleanup', + 'npm run build:cleanup', 'npm run lint', 'npm run test:coverage', ], - 'before:npm:release': ['npm run dist:build'], - 'after:npm:release': ['npm run dist:cleanup'], + 'before:npm:release': ['npm run build'], + 'after:npm:release': ['npm run build:cleanup'], }, }; diff --git a/src/js/client/request/chunk/JsonClientRequest.js b/src/js/client/request/chunk/JsonClientRequest.js index 845a4c7..c7adc9e 100644 --- a/src/js/client/request/chunk/JsonClientRequest.js +++ b/src/js/client/request/chunk/JsonClientRequest.js @@ -44,8 +44,8 @@ module.exports = class JsonClientRequest { return this.#origin.response; } - send() { - return this.#origin + async send() { + return await this.#origin .with({ body: this.body, options: this.options, diff --git a/src/js/client/response/chunk/JsonClientResponse.js b/src/js/client/response/chunk/JsonClientResponse.js index 655a6fe..1058e4a 100644 --- a/src/js/client/response/chunk/JsonClientResponse.js +++ b/src/js/client/response/chunk/JsonClientResponse.js @@ -50,10 +50,13 @@ module.exports = class JsonClientResponse { }), }); } catch (e) { - if (!(e instanceof SyntaxError)) { - throw new Error('JSON client response error', { - cause: { error: e, code: 'RESPONSE_ERROR' }, - }); + if (e instanceof SyntaxError) { + throw new Error( + `Invalid client json response. Body was ${accepted.body}`, + { + cause: { error: e, code: 'RESPONSE_ERROR' }, + }, + ); } throw e; diff --git a/src/js/server/request/chunk/JsonServerRequest.js b/src/js/server/request/chunk/JsonServerRequest.js index 221fec3..d6c4355 100644 --- a/src/js/server/request/chunk/JsonServerRequest.js +++ b/src/js/server/request/chunk/JsonServerRequest.js @@ -56,9 +56,12 @@ module.exports = class JsonServerRequest { }); } catch (e) { if (e instanceof SyntaxError) { - throw new Error('Invalid server json request', { - cause: { error: e, code: 'INVALID_REQUEST' }, - }); + throw new Error( + `Invalid server json request. Body was ${accepted.body}`, + { + cause: { error: e, code: 'INVALID_REQUEST' }, + }, + ); } throw e;