From 3e25203b10e4152ab00aa7fd827affdf3d9e765b Mon Sep 17 00:00:00 2001 From: Elmar Athmer Date: Sat, 18 May 2024 15:50:01 +0200 Subject: [PATCH] use toError (from fp-ts) instead of ensure-error --- package-lock.json | 17 ----------------- package.json | 1 - src/errors/input.ts | 4 ++-- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index bdb8d4a..9845b62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "dependencies": { "axios": "^1.3.5", "cors": "^2.8.5", - "ensure-error": "^3.0.1", "express": "^4.18.2", "express-promise-router": "^4.1.1", "fp-ts": "^2.13.1", @@ -2598,17 +2597,6 @@ "once": "^1.4.0" } }, - "node_modules/ensure-error": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ensure-error/-/ensure-error-3.0.1.tgz", - "integrity": "sha512-J2e5Z3sgnA8en6+alf2VkO5cRwe75hHgSw0rJiMn5CEE4Yyw6GSgH31IBgwN9lugeCuPKHzuOF3X/RozAFsuhQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -8318,11 +8306,6 @@ "once": "^1.4.0" } }, - "ensure-error": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ensure-error/-/ensure-error-3.0.1.tgz", - "integrity": "sha512-J2e5Z3sgnA8en6+alf2VkO5cRwe75hHgSw0rJiMn5CEE4Yyw6GSgH31IBgwN9lugeCuPKHzuOF3X/RozAFsuhQ==" - }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", diff --git a/package.json b/package.json index f390bcf..ac5c349 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "dependencies": { "axios": "^1.3.5", "cors": "^2.8.5", - "ensure-error": "^3.0.1", "express": "^4.18.2", "express-promise-router": "^4.1.1", "fp-ts": "^2.13.1", diff --git a/src/errors/input.ts b/src/errors/input.ts index ef0dec2..16acfd4 100644 --- a/src/errors/input.ts +++ b/src/errors/input.ts @@ -1,5 +1,5 @@ import { InternalServerError, UnprocessableEntityError } from "./http"; -import { Left } from "fp-ts/Either"; +import { Left, toError } from "fp-ts/Either"; import { Errors } from "io-ts"; import { PathReporter } from "io-ts/PathReporter"; import ensureError from "ensure-error"; @@ -18,7 +18,7 @@ export class InputDecodingFailedError extends UnprocessableEntityError { export class UnknownError extends InternalServerError { constructor(cause: unknown) { - const error = ensureError(cause); + const error = toError(cause); super("Unknown error occurred: " + error.message, error); }