Files
triggerdotdev--trigger.dev/apps/webapp/app/utils/formatErrors.server.ts
Matt Aitken 9ff4c0dbd5 Project-wide Prettier setup (#237)
* Setup project-wide prettier

* Remove old workspace file

* Remove old debugging directives

* New top-level .prettierignore

* Updated Prettier config settings

* Contrubuting guide: Fix for some bad code blocks

* Added more ignores

* Improved the format script command

* printWidth set to 100

* Formatted entire repo (pnpm run format)
2023-08-01 10:21:22 +01:00

20 lines
609 B
TypeScript

import { ErrorWithStack, ErrorWithStackSchema } from "@trigger.dev/core";
export function formatError(error: ErrorWithStack, style: "short" | "long" = "short"): string {
if (style === "short") {
return error.name ? `${error.name}: ${error.message}` : error.message;
}
return formatError(error, "short") + "\n" + error.stack;
}
export function formatUnknownError(error: unknown, style: "short" | "long" = "short"): string {
const parsedError = ErrorWithStackSchema.safeParse(error);
if (parsedError.success) {
return formatError(parsedError.data, style);
}
return "Unknown error";
}