feat: pretty-print-error to print errors in console (#1596)

Co-authored-by: Manuel <30572287+manuel-rw@users.noreply.github.com>
This commit is contained in:
Meier Lukas
2024-12-05 17:24:23 +01:00
committed by GitHub
parent 86cd1017b9
commit 71f4f8c4c8
5 changed files with 39 additions and 1 deletions

View File

@@ -45,5 +45,10 @@
"packageManager": "pnpm@9.14.4",
"engines": {
"node": ">=22.12.0"
},
"pnpm": {
"patchedDependencies": {
"pretty-print-error": "patches/pretty-print-error.patch"
}
}
}

View File

@@ -29,6 +29,7 @@
"@homarr/log": "workspace:^0.1.0",
"@homarr/redis": "workspace:^0.1.0",
"dayjs": "^1.11.13",
"pretty-print-error": "^1.1.2",
"superjson": "2.2.1"
},
"devDependencies": {

View File

@@ -1,3 +1,4 @@
import { formatError } from "pretty-print-error";
import SuperJSON from "superjson";
import { hashObjectBase64, Stopwatch } from "@homarr/common";
@@ -95,7 +96,7 @@ export const createRequestIntegrationJobHandler = <
);
} catch (error) {
logger.error(
`Failed to run integration job integration=${integrationId} inputHash='${inputHash}' error=${error as string}`,
`Failed to run integration job integration=${integrationId} inputHash='${inputHash}' error=${formatError(error)}`,
);
}
}

View File

@@ -0,0 +1,16 @@
diff --git a/src/index.ts b/src/index.ts
index c8f62a743b89040c1d10a8ae3795bec8afcbc134..7cd7c1e98c1c9516b40f678627f51fd1adfa18c7 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -109,9 +109,9 @@ export function formatError(
(name) => name !== "stack" && name !== "message"
);
if (propNames.length > 0) {
- const props = {};
+ const props: Record<string, unknown> = {};
propNames.forEach((name) => {
- props[name] = err[name];
+ props[name] = (err as Record<string, object>)[name];
});
let propertiesString;

15
pnpm-lock.yaml generated
View File

@@ -4,6 +4,11 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
patchedDependencies:
pretty-print-error:
hash: 4arrfgbz7em6s4gqywse7esg4u
path: patches/pretty-print-error.patch
importers:
.:
@@ -1341,6 +1346,9 @@ importers:
dayjs:
specifier: ^1.11.13
version: 1.11.13
pretty-print-error:
specifier: ^1.1.2
version: 1.1.2(patch_hash=4arrfgbz7em6s4gqywse7esg4u)
superjson:
specifier: 2.2.1
version: 2.2.1
@@ -6768,6 +6776,9 @@ packages:
resolution: {integrity: sha512-ASJqOugUF1bbzI35STMBUpZqdfYKlJugy6JBziGi2EE+AL5JPJGSzvpeVXojxrr0ViUYoToUjb5kjSEGf7Y83Q==}
engines: {node: '>=14.16'}
pretty-print-error@1.1.2:
resolution: {integrity: sha512-XkKN3W8aeRYApO17WpzuaJZmqH3WNSFeqR4Sxt7vu+C7pcWB+3+JDJ2dnnhzSCqvC1IaYR36CVh4VsFZyBicQA==}
prismjs@1.27.0:
resolution: {integrity: sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==}
engines: {node: '>=6'}
@@ -13667,6 +13678,10 @@ snapshots:
dependencies:
parse-ms: 3.0.0
pretty-print-error@1.1.2(patch_hash=4arrfgbz7em6s4gqywse7esg4u):
dependencies:
kleur: 4.1.5
prismjs@1.27.0: {}
prismjs@1.29.0: {}