Skip to content

Commit

Permalink
fix: exit on uncaught exceptions by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Jul 21, 2024
1 parent 731a238 commit 8e2e91a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-zoos-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/belt': patch
---

fix: exit on uncaught exceptions by default
82 changes: 41 additions & 41 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
"devDependencies": {
"@changesets/changelog-git": "^0.2.0",
"@ryanatkn/eslint-config": "^0.4.2",
"@ryanatkn/fuz": "^0.115.1",
"@ryanatkn/gro": "^0.133.1",
"@ryanatkn/moss": "^0.8.0",
"@ryanatkn/fuz": "^0.117.0",
"@ryanatkn/gro": "^0.133.3",
"@ryanatkn/moss": "^0.10.1",
"@sveltejs/adapter-static": "^3.0.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/package": "^2.3.2",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/node": "^20.14.10",
"@types/node": "^20.14.11",
"eslint": "^9.7.0",
"eslint-plugin-svelte": "^2.42.0",
"eslint-plugin-svelte": "^2.43.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.5",
"svelte": "^5.0.0-next.184",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "^5.0.0-next.193",
"svelte-check": "^3.8.4",
"tinybench": "^2.8.0",
"tslib": "^2.6.3",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,20 @@ export const despawn_all = (): Promise<Spawn_Result[]> =>
*/
export const attach_process_error_handlers = (
to_error_label?: (err: Error, origin: NodeJS.UncaughtExceptionOrigin) => string | null,
map_error_text?: (err: Error) => string | null,
map_error_text?: (err: Error, origin: NodeJS.UncaughtExceptionOrigin) => string | null,
handle_error: (err: Error, origin: NodeJS.UncaughtExceptionOrigin) => void = () =>
process.exit(1),
): void => {
process.on('uncaughtException', async (err, origin): Promise<void> => {
const label = to_error_label?.(err, origin) ?? origin;
if (label) {
const error_text = map_error_text?.(err) ?? print_error(err);
const error_text = map_error_text?.(err, origin) ?? print_error(err);
if (error_text) {
new System_Logger(print_log_label(label, red)).error(error_text);
}
}
await despawn_all();
handle_error(err, origin);
});
};

Expand Down
14 changes: 7 additions & 7 deletions src/routes/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ export const package_json = {
devDependencies: {
'@changesets/changelog-git': '^0.2.0',
'@ryanatkn/eslint-config': '^0.4.2',
'@ryanatkn/fuz': '^0.115.1',
'@ryanatkn/gro': '^0.133.1',
'@ryanatkn/moss': '^0.8.0',
'@ryanatkn/fuz': '^0.117.0',
'@ryanatkn/gro': '^0.133.3',
'@ryanatkn/moss': '^0.10.1',
'@sveltejs/adapter-static': '^3.0.2',
'@sveltejs/kit': '^2.5.18',
'@sveltejs/package': '^2.3.2',
'@sveltejs/vite-plugin-svelte': '^3.1.1',
'@types/node': '^20.14.10',
'@types/node': '^20.14.11',
eslint: '^9.7.0',
'eslint-plugin-svelte': '^2.42.0',
'eslint-plugin-svelte': '^2.43.0',
prettier: '^3.3.3',
'prettier-plugin-svelte': '^3.2.5',
svelte: '^5.0.0-next.184',
'prettier-plugin-svelte': '^3.2.6',
svelte: '^5.0.0-next.193',
'svelte-check': '^3.8.4',
tinybench: '^2.8.0',
tslib: '^2.6.3',
Expand Down

0 comments on commit 8e2e91a

Please sign in to comment.