Skip to content

Commit e05786a

Browse files
committed
fix(ses): fix 2943 error trapping issues
1 parent 37d8080 commit e05786a

File tree

5 files changed

+4
-2
lines changed

5 files changed

+4
-2
lines changed

packages/ses/error-codes/SES_UNCAUGHT_EXCEPTION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This behavior is configured by calling `lockdown` with the [errorTrapping][] opt
66

77
Otherwise, when thrown exceptions have no `catch` handler, the SES shim will print `SES_UNCAUGHT_EXCEPTION: exception...` to the error console. In that case, `exception...` is the thrown exception, augmented with causal error information when possible.
88

9+
On some platforms, the default errorTrapping behavior reports the error, but the platform's user trapping mechanism reports only an event with no error. (See https://github.com/endojs/endo/issues/2941 test1.) In that case, non-default `errorTrapping` reports the event about the error, rather than the error itself. This often has much less relevant information.
10+
911
For most programs, the error console is intended for human consumption, and so the `SES_UNCAUGHT_EXCEPTION:` output can be useful in giving a clue as to the source of a failure.
1012

1113
[errorTrapping]: ../docs/lockdown.md#errortrapping-options

packages/ses/src/error/tame-console.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const tameConsole = (
156156
globalWindow.addEventListener('error', event => {
157157
event.preventDefault();
158158
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_UNCAUGHT_EXCEPTION.md
159-
ourConsole.error('SES_UNCAUGHT_EXCEPTION:', event.error);
159+
ourConsole.error('SES_UNCAUGHT_EXCEPTION:', event.error || event);
160160
// 'platform' and 'report' just log the reason.
161161
if (errorTrapping === 'exit' || errorTrapping === 'abort') {
162162
globalWindow.location.href = `about:blank`;
77.6 KB
Loading
82.1 KB
Loading

packages/ses/test/error/issue-2941/test3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Nested error under Error#1
1919
# `errorTrapping" 'platform', errorTaming: 'safe'`
2020

2121
```
22-
$ node error-trapping-platformsafe.demo.js
22+
$ node error-trapping-platform-safe.demo.js
2323
SES_UNCAUGHT_EXCEPTION: (Error#1)
2424
Error#1: que?
2525
at packages/ses/test/error/issue-2941/test3/error-trapping-platform.demo.js:12:9

0 commit comments

Comments
 (0)