Skip to content

Commit

Permalink
feat: pretty-print-error to print errors in console
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Dec 2, 2024
1 parent a1a6dc9 commit 6f98698
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@
"packageManager": "[email protected]",
"engines": {
"node": ">=22.11.0"
},
"pnpm": {
"patchedDependencies": {
"pretty-print-error": "patches/pretty-print-error.patch"
}
}
}
1 change: 1 addition & 0 deletions packages/request-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { inferSupportedIntegrationsStrict } from "../../../widgets/src";
import { reduceWidgetOptionsWithDefaultValues } from "../../../widgets/src";
import type { WidgetComponentProps } from "../../../widgets/src/definition";
import type { createCachedIntegrationRequestHandler } from "./cached-integration-request-handler";
import { formatError } from "pretty-print-error";

export const createRequestIntegrationJobHandler = <
TWidgetKind extends WidgetKind,
Expand Down Expand Up @@ -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)}`,
);
}
}
Expand Down
16 changes: 16 additions & 0 deletions patches/pretty-print-error.patch
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f98698

Please sign in to comment.