File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ unreleased
2
+ ==========
3
+
4
+ * Fix exception when global ` Error.stackTraceLimit ` is too low
5
+
1
6
0.4.2 / 2014-07-19
2
7
==================
3
8
Original file line number Diff line number Diff line change @@ -363,15 +363,18 @@ function formatLocation(callSite) {
363
363
*/
364
364
365
365
function getStack ( ) {
366
+ var limit = Error . stackTraceLimit
366
367
var obj = { }
367
368
var prep = Error . prepareStackTrace
368
369
369
370
Error . prepareStackTrace = prepareObjectStackTrace
371
+ Error . stackTraceLimit = Math . max ( 10 , limit )
370
372
Error . captureStackTrace ( obj , getStack )
371
373
372
374
var stack = obj . stack
373
375
374
376
Error . prepareStackTrace = prep
377
+ Error . stackTraceLimit = limit
375
378
376
379
return stack
377
380
}
Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ describe('deprecate(message)', function () {
40
40
stderr . should . match ( / \. j s : [ 0 - 9 ] + : [ 0 - 9 ] + / )
41
41
} )
42
42
43
+ it ( 'should log call site regardless of Error.stackTraceLimit' , function ( ) {
44
+ function callold ( ) { mylib . old ( ) }
45
+ var limit = Error . stackTraceLimit
46
+ try {
47
+ Error . stackTraceLimit = 1
48
+ var stderr = captureStderr ( callold )
49
+ stderr . should . containEql ( basename ( __filename ) )
50
+ stderr . should . match ( / \. j s : [ 0 - 9 ] + : [ 0 - 9 ] + / )
51
+ } finally {
52
+ Error . stackTraceLimit = limit
53
+ }
54
+ } )
55
+
43
56
it ( 'should log call site within eval' , function ( ) {
44
57
function callold ( ) { eval ( 'mylib.old()' ) }
45
58
var stderr = captureStderr ( callold )
You can’t perform that action at this time.
0 commit comments