Skip to content

Commit

Permalink
fix(http-error): add code, status, and statusCode
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 26, 2024
1 parent 9d29748 commit a2df56e
Show file tree
Hide file tree
Showing 5 changed files with 614 additions and 1,526 deletions.
324 changes: 162 additions & 162 deletions .yarn/releases/yarn-4.1.0.cjs → .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ compressionLevel: mixed

enableGlobalCache: false

yarnPath: .yarn/releases/yarn-4.1.0.cjs
yarnPath: .yarn/releases/yarn-4.1.1.cjs
10 changes: 8 additions & 2 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,22 @@ export class TimeoutError extends PTimeoutError {
export async function fixError<
E extends {
message?: string;
code?: string;
status?: string | number;
statusCode?: string | number;
statusText?: string;
},
>(error: E): Promise<E & Error> {
// Try to normalize the various ways of sending the error codes
const code = `${error.code ?? error.status ?? error.statusCode}`;
error.code ??= code;
error.status ??= Number(code);
error.statusCode ??= Number(code);

if (error instanceof Error) {
return error;
}

const code = `${error.status}`;

// TODO: Clean up this mess
let body: { message?: string } = {};
try {
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oada/client",
"version": "5.0.0",
"version": "5.0.1",
"description": "A lightweight client tool to interact with an OADA-compliant server",
"repository": "https://github.com/OADA/client",
"main": "./dist/index.js",
Expand Down Expand Up @@ -121,7 +121,7 @@
"isomorphic-timers-promises": "^1.0.1",
"isomorphic-ws": "^5.0.0",
"json-ptr": "^3.1.1",
"jsonpath-plus": "^8.0.0",
"jsonpath-plus": "^8.1.0",
"media-type": "^0.3.1",
"object-assign-deep": "^0.4.0",
"p-queue": "^8.0.1",
Expand All @@ -130,7 +130,7 @@
"resolve-alpn": "^1.2.1",
"serialize-error": "^11.0.3",
"tslib": "^2.6.2",
"undici": "^6.6.2",
"undici": "^6.14.1",
"ws": "^8.16.0",
"xksuid": "https://github.com/aultac/xksuid.git#commit=22a21eb01331191feb62ea0a4e67d96d2e80f396"
},
Expand All @@ -144,24 +144,24 @@
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
"@oada/jobs": "^4.4.4",
"@oada/jobs": "^4.5.1",
"@skypack/package-check": "^0.2.2",
"@tsconfig/node18": "^18.2.2",
"@tsconfig/node18": "^18.2.4",
"@types/debug": "^4.1.12",
"@types/node": "^20.11.24",
"@types/node": "^20.12.7",
"@types/object-assign-deep": "^0.4.3",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@yarnpkg/sdks": "3.1.0",
"ava": "6.1.2",
"c8": "^9.1.0",
"dotenv": "^16.4.5",
"esbuild": "^0.20.1",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-xo": "^0.44.0",
"eslint-config-xo-typescript": "^3.0.0",
"eslint-config-xo-typescript": "^4.0.0",
"eslint-formatter-pretty": "^6.0.1",
"eslint-import-resolver-node": "^0.3.9",
"eslint-plugin-array-func": "^5.0.1",
Expand All @@ -174,20 +174,20 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-no-secrets": "^0.9.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^2.2.0",
"eslint-plugin-security": "^2.1.1",
"eslint-plugin-sonarjs": "^0.24.0",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-regexp": "^2.5.0",
"eslint-plugin-security": "^3.0.0",
"eslint-plugin-sonarjs": "^0.25.1",
"eslint-plugin-unicorn": "^52.0.0",
"prettier": "^3.2.5",
"typescript": "5.3.3"
"typescript": "5.4.5"
},
"packageManager": "[email protected].0",
"packageManager": "[email protected].1",
"volta": {
"node": "20.11.1"
},
Expand Down
Loading

0 comments on commit a2df56e

Please sign in to comment.