Skip to content

Commit

Permalink
fix: Catch errors when emitting events to prevent breaking entire lay…
Browse files Browse the repository at this point in the history
…out (#1353)

- Added a try/catch around all events that are emitted from Golden
Layout
- Added @deephaven/log to golden layout so we can log the error
- Tested using the steps in
https://github.com/deephaven/deephaven-js-plugins/issues/26
- Fixes #1352
  • Loading branch information
mofojed authored Jun 8, 2023
1 parent 5e0db54 commit aac5bd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 10 additions & 2 deletions packages/golden-layout/src/utils/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ class EventEmitter {
if (subs) {
for (let i = 0; i < subs.length; i++) {
const ctx = subs[i].ctx || {};
subs[i].fn.apply(ctx, args);
try {
subs[i].fn.apply(ctx, args);
} catch (e) {
console.error('Error while emitting event:', e);
}
}
}

Expand All @@ -75,7 +79,11 @@ class EventEmitter {

for (let i = 0; i < allEventSubs.length; i++) {
const ctx = allEventSubs[i].ctx || {};
allEventSubs[i].fn.apply(ctx, args);
try {
allEventSubs[i].fn.apply(ctx, args);
} catch (e) {
console.error('Error while emitting event to allEventSubs:', e);
}
}
}

Expand Down
13 changes: 3 additions & 10 deletions packages/golden-layout/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
"rootDir": "src/",
"outDir": "dist/"
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.js",
"src/**/*.jsx"
],
"exclude": [
"node_modules"
]
}
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
"exclude": ["node_modules"]
}

0 comments on commit aac5bd2

Please sign in to comment.