Skip to content

Commit 4f6bd20

Browse files
fix: catch error when logging args
1 parent 042f84e commit 4f6bd20

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/bidiMapper/modules/log/LogManager.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,30 @@ export class LogManager {
118118
);
119119
for (const browsingContext of realm.associatedBrowsingContexts) {
120120
this.#eventManager.registerPromiseEvent(
121-
argsPromise.then((args) => ({
122-
kind: 'success',
123-
value: {
124-
type: 'event',
125-
method: ChromiumBidi.Log.EventNames.LogEntryAdded,
126-
params: {
127-
level: getLogLevel(params.type),
128-
source: realm.source,
129-
text: getRemoteValuesText(args, true),
130-
timestamp: Math.round(params.timestamp),
131-
stackTrace: getBidiStackTrace(params.stackTrace),
132-
type: 'console',
133-
// Console method is `warn`, not `warning`.
134-
method: params.type === 'warning' ? 'warn' : params.type,
135-
args,
121+
argsPromise.then(
122+
(args) => ({
123+
kind: 'success',
124+
value: {
125+
type: 'event',
126+
method: ChromiumBidi.Log.EventNames.LogEntryAdded,
127+
params: {
128+
level: getLogLevel(params.type),
129+
source: realm.source,
130+
text: getRemoteValuesText(args, true),
131+
timestamp: Math.round(params.timestamp),
132+
stackTrace: getBidiStackTrace(params.stackTrace),
133+
type: 'console',
134+
// Console method is `warn`, not `warning`.
135+
method: params.type === 'warning' ? 'warn' : params.type,
136+
args,
137+
},
136138
},
137-
},
138-
})),
139+
}),
140+
(error) => ({
141+
kind: 'error',
142+
error,
143+
})
144+
),
139145
browsingContext.id,
140146
ChromiumBidi.Log.EventNames.LogEntryAdded
141147
);

0 commit comments

Comments
 (0)