Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/internal/process/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ const report = {
},
getReport(err) {
emitExperimentalWarning('report');
if (err == null) {
return nr.getReport(new ERR_SYNTHETIC().stack);
} else if (typeof err !== 'object') {

if (err === undefined)
err = new ERR_SYNTHETIC();
else if (err === null || typeof err !== 'object')
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
} else {
return nr.getReport(err.stack);
}

return nr.getReport(err.stack);
}
};

Expand Down
21 changes: 19 additions & 2 deletions test/node-report/test-api-getreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,22 @@ const helper = require('../common/report');
common.expectWarning('ExperimentalWarning',
'report is an experimental feature. This feature could ' +
'change at any time');
helper.validateContent(process.report.getReport());
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);

{
// Test with no arguments.
helper.validateContent(process.report.getReport());
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
}

{
// Test with an error argument.
helper.validateContent(process.report.getReport(new Error('test error')));
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
}

// Test with an invalid error argument.
[null, 1, Symbol(), function() {}, 'foo'].forEach((error) => {
common.expectsError(() => {
process.report.getReport(error);
}, { code: 'ERR_INVALID_ARG_TYPE' });
});