Permalink
Browse files

test: improve error logging for inspector test

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 <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information...
Trott committed Jul 27, 2017
1 parent 7128e3c commit bfb4f4224d9f8f87944d611dd569d1d3579f5523
Showing with 9 additions and 2 deletions.
  1. +9 −2 test/inspector/inspector-helper.js
@@ -73,8 +73,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);

0 comments on commit bfb4f42

Please sign in to comment.