mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Allow Error.prepareStackTrace to be temporarily reassigned
Fixes https://github.com/atom/atom/issues/9660 Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
parent
d17ab332ec
commit
4616b426b0
@ -69,3 +69,15 @@ describe 'CompileCache', ->
|
||||
|
||||
CompileCache.addPathToCache(path.join(fixtures, 'cson.cson'), atomHome)
|
||||
expect(CSONParser.parse.callCount).toBe 1
|
||||
|
||||
describe 'overriding Error.prepareStackTrace', ->
|
||||
it 'removes the override on the next tick', ->
|
||||
Error.prepareStackTrace = -> 'a-stack-trace'
|
||||
|
||||
error = new Error("Oops")
|
||||
expect(error.stack).toBe 'a-stack-trace'
|
||||
|
||||
waits(1)
|
||||
runs ->
|
||||
error = new Error("Oops again")
|
||||
expect(error.stack).not.toBe 'a-stack-trace'
|
||||
|
@ -166,10 +166,17 @@ function prepareStackTraceWithRawStack (error, frames) {
|
||||
return sourceMapPrepareStackTrace(error, frames)
|
||||
}
|
||||
|
||||
let prepareStackTrace = prepareStackTraceWithRawStack
|
||||
|
||||
// Prevent coffee-script from reassigning Error.prepareStackTrace
|
||||
Object.defineProperty(Error, 'prepareStackTrace', {
|
||||
get: function () { return prepareStackTraceWithRawStack },
|
||||
set: function (newValue) {}
|
||||
get: function () { return prepareStackTrace },
|
||||
set: function (newValue) {
|
||||
prepareStackTrace = newValue
|
||||
process.nextTick(function () {
|
||||
prepareStackTrace = prepareStackTraceWithRawStack
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Error.prototype.getRawStack = function () { // eslint-disable-line no-extend-native
|
||||
|
Loading…
Reference in New Issue
Block a user