Skip to content

Commit

Permalink
test: improve error logging for inspector test
Browse files Browse the repository at this point in the history
If JSON.parse() fails, print a message showing the JSON that failed to
parse. This is to help with debugging a current test failure on CI.

PR-URL: #14508
Ref: #14507
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Aug 16, 2017
1 parent b9a5253 commit baa11a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/inspector/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ function parseWSFrame(buffer, handler) {
}
if (buffer.length < bodyOffset + dataLen)
return 0;
const message = JSON.parse(
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'));
const jsonPayload =
buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8');
let message;
try {
message = JSON.parse(jsonPayload);
} catch (e) {
console.error(`JSON.parse() failed for: ${jsonPayload}`);
throw e;
}
if (DEBUG)
console.log('[received]', JSON.stringify(message));
handler(message);
Expand Down

0 comments on commit baa11a1

Please sign in to comment.