Skip to content
Closed
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,14 @@ Raven.prototype = {
return this.captureMessage(
ex,
objectMerge(
objectMerge(
{
stacktrace: true // if we fall back to captureMessage, default to attempting a new trace
},
options),
{
trimHeadFrames: 1,
stacktrace: true // if we fall back to captureMessage, default to attempting a new trace
},
options
trimHeadFrames: ((options && options.trimHeadFrames) || 0) + 1,
Copy link
Contributor

@kamilogorek kamilogorek Feb 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set the default for options at the top of the method while also making a copy?

options = options ? Object.merge({}, options) : {}

and then just leave (options.trimHeadFrames || 0) + 1?

We also don't need a double objectMerge, as it can be done in a single call when we do so:

objectMerge(options, {
  stacktrace: true,
  trimHeadFrames: (options.trimHeadFrames || 0) + 1
})

Although I'm not sure if we cannot just reverse it, even though it's reference and write

objectMerge(options, {
  stacktrace: true,
  trimHeadFrames: (options.trimHeadFrames || 0) + 1
})

without making a copy, as objectMerge is just reassigning values by key anyway.

Copy link
Contributor Author

@leth leth Feb 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea! Thanks!

}
)
);
}
Expand Down