Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/browser/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ function addBodyMessage(item, options, callback) {
callback(null, item);
}

function stackFromItem(item) {
function stackFromItem(item, stackInfo = null) {
// Transform a TraceKit stackInfo object into a Rollbar trace
var stack = item.stackInfo.stack;
let stack = (stackInfo || item.stackInfo).stack;
if (
stack &&
stack.length === 0 &&
Expand Down Expand Up @@ -230,7 +230,7 @@ function addBodyTrace(item, options, callback) {
function buildTrace(item, stackInfo, options) {
var description = item && item.data.description;
var custom = item && item.custom;
var stack = stackFromItem(item);
var stack = stackFromItem(item, stackInfo);

var guess = errorParser.guessErrorClass(stackInfo.message);
var className = errorClass(stackInfo, guess[0], options);
Expand Down
15 changes: 11 additions & 4 deletions test/browser.rollbar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ describe('options.captureUncaught', function () {
captureUncaught: false,
});
});

it('should send DOMException as trace_chain', async function () {
const server = window.server;
stubResponse(server);
Expand All @@ -558,9 +559,15 @@ describe('options.captureUncaught', function () {

const body = JSON.parse(server.requests[0].requestBody);

expect(body.data.body.trace_chain[0].exception.message).to.eql(
'test DOMException',
);
expect(body.data.body.trace_chain[0].exception).to.eql({
class: 'Error',
message: 'test DOMException',
description: 'Uncaught Error: test DOMException',
});
expect(body.data.body.trace_chain[1].exception).to.eql({
class: 'DOMException',
message: 'test DOMException',
});

// karma doesn't unload the browser between tests, so the onerror handler
// will remain installed. Unset captureUncaught so the onerror handler
Expand All @@ -570,7 +577,7 @@ describe('options.captureUncaught', function () {
});
});

it('should capture exta frames when stackTraceLimit is set', async function () {
it('should capture extra frames when stackTraceLimit is set', async function () {
const server = window.server;
stubResponse(server);
server.requests.length = 0;
Expand Down
3 changes: 3 additions & 0 deletions test/browser.transforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ describe('addBody', function () {
expect(i.data.body.trace_chain[1].exception.message).to.eql(
'nested error',
);
expect(i.data.body.trace_chain[0].frames.at(-1).lineno).to.not.eql(
i.data.body.trace_chain[1].frames.at(-1).lineno,
);
done(e);
});
});
Expand Down