Skip to content

Commit ca6ca26

Browse files
committed
1.1.11
1 parent 11645a0 commit ca6ca26

File tree

6 files changed

+53
-52
lines changed

6 files changed

+53
-52
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raven-js",
3-
"version": "1.1.10",
3+
"version": "1.1.11",
44
"dependencies": {},
55
"main": "dist/raven.js"
66
}

dist/raven.js

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 1.1.10 (e96d774) | github.com/getsentry/raven-js */
1+
/*! Raven.js 1.1.11 (11645a0) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
@@ -89,6 +89,7 @@ TraceKit.wrap = function traceKitWrapper(func) {
8989
*/
9090
TraceKit.report = (function reportModuleWrapper() {
9191
var handlers = [],
92+
lastArgs = null,
9293
lastException = null,
9394
lastExceptionStack = null;
9495

@@ -125,9 +126,9 @@ TraceKit.report = (function reportModuleWrapper() {
125126
* Dispatch stack information to all handlers.
126127
* @param {Object.<string, *>} stack
127128
*/
128-
function notifyHandlers(stack, windowError) {
129+
function notifyHandlers(stack, isWindowError) {
129130
var exception = null;
130-
if (windowError && !TraceKit.collectWindowErrors) {
131+
if (isWindowError && !TraceKit.collectWindowErrors) {
131132
return;
132133
}
133134
for (var i in handlers) {
@@ -159,19 +160,17 @@ TraceKit.report = (function reportModuleWrapper() {
159160
* @param {?Error} ex The actual Error object.
160161
*/
161162
function traceKitWindowOnError(message, url, lineNo, colNo, ex) {
162-
var stack = null, skipNotify = false;
163+
var stack = null;
163164

164-
if (!isUndefined(ex)) {
165+
if (lastExceptionStack) {
166+
TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message);
167+
processLastException();
168+
} else if (ex) {
165169
// New chrome and blink send along a real error object
166170
// Let's just report that like a normal error.
167171
// See: https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror
168-
report(ex, false);
169-
skipNotify = true;
170-
} else if (lastExceptionStack) {
171-
TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message);
172-
stack = lastExceptionStack;
173-
lastExceptionStack = null;
174-
lastException = null;
172+
stack = TraceKit.computeStackTrace(ex);
173+
notifyHandlers(stack, true);
175174
} else {
176175
var location = {
177176
'url': url,
@@ -181,16 +180,11 @@ TraceKit.report = (function reportModuleWrapper() {
181180
location.func = TraceKit.computeStackTrace.guessFunctionName(location.url, location.line);
182181
location.context = TraceKit.computeStackTrace.gatherContext(location.url, location.line);
183182
stack = {
184-
'mode': 'onerror',
185183
'message': message,
186184
'url': document.location.href,
187-
'stack': [location],
188-
'useragent': navigator.userAgent
185+
'stack': [location]
189186
};
190-
}
191-
192-
if (!skipNotify) {
193-
notifyHandlers(stack, 'from window.onerror');
187+
notifyHandlers(stack, true);
194188
}
195189

196190
if (_oldOnerrorHandler) {
@@ -220,6 +214,15 @@ TraceKit.report = (function reportModuleWrapper() {
220214
_oldOnerrorHandler = undefined;
221215
}
222216

217+
function processLastException() {
218+
var _lastExceptionStack = lastExceptionStack,
219+
_lastArgs = lastArgs;
220+
lastArgs = null;
221+
lastExceptionStack = null;
222+
lastException = null;
223+
notifyHandlers.apply(null, [_lastExceptionStack, false].concat(_lastArgs));
224+
}
225+
223226
/**
224227
* Reports an unhandled Error to TraceKit.
225228
* @param {Error} ex
@@ -233,26 +236,22 @@ TraceKit.report = (function reportModuleWrapper() {
233236
if (lastException === ex) {
234237
return; // already caught by an inner catch block, ignore
235238
} else {
236-
var s = lastExceptionStack;
237-
lastExceptionStack = null;
238-
lastException = null;
239-
notifyHandlers.apply(null, [s, null].concat(args));
239+
processLastException();
240240
}
241241
}
242242

243243
var stack = TraceKit.computeStackTrace(ex);
244244
lastExceptionStack = stack;
245245
lastException = ex;
246+
lastArgs = args;
246247

247248
// If the stack trace is incomplete, wait for 2 seconds for
248249
// slow slow IE to see if onerror occurs or not before reporting
249250
// this exception; otherwise, we will end up with an incomplete
250251
// stack trace
251252
window.setTimeout(function () {
252253
if (lastException === ex) {
253-
lastExceptionStack = null;
254-
lastException = null;
255-
notifyHandlers.apply(null, [stack, null].concat(args));
254+
processLastException();
256255
}
257256
}, (stack.incomplete ? 2000 : 0));
258257

@@ -282,7 +281,6 @@ TraceKit.report = (function reportModuleWrapper() {
282281
* s.stack[i].line - line number, if known
283282
* s.stack[i].column - column number, if known
284283
* s.stack[i].context - an array of source code lines; the middle element corresponds to the correct line#
285-
* s.mode - 'stack', 'stacktrace', 'multiline', 'callers', 'onerror', or 'failed' -- method used to collect the stack trace
286284
*
287285
* Supports:
288286
* - Firefox: full stack trace with line numbers and unreliable column
@@ -373,6 +371,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
373371
* @return {Array.<string>} Source contents.
374372
*/
375373
function getSource(url) {
374+
if (!isString(url)) return [];
376375
if (!hasKey(sourceCache, url)) {
377376
// URL needs to be able to fetched within the acceptable domain. Otherwise,
378377
// cross-domain errors will be triggered.
@@ -614,6 +613,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
614613
// ex.message = qq is not defined
615614
// ex.fileName = http://...
616615
// ex.lineNumber = 59
616+
// ex.columnNumber = 69
617617
// ex.stack = ...stack trace... (see the example below)
618618
// ex.name = ReferenceError
619619
//
@@ -684,21 +684,24 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
684684
stack.push(element);
685685
}
686686

687-
if (stack[0] && stack[0].line && !stack[0].column && reference) {
688-
stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line);
689-
}
690-
691687
if (!stack.length) {
692688
return null;
693689
}
694690

691+
if (stack[0].line && !stack[0].column && reference) {
692+
stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line);
693+
} else if (!stack[0].column && !isUndefined(ex.columnNumber)) {
694+
// FireFox uses this awesome columnNumber property for its top frame
695+
// Also note, Firefox's column number is 0-based and everything else expects 1-based,
696+
// so adding 1
697+
stack[0].column = ex.columnNumber + 1;
698+
}
699+
695700
return {
696-
'mode': 'stack',
697701
'name': ex.name,
698702
'message': ex.message,
699703
'url': document.location.href,
700-
'stack': stack,
701-
'useragent': navigator.userAgent
704+
'stack': stack
702705
};
703706
}
704707

@@ -751,12 +754,10 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
751754
}
752755

753756
return {
754-
'mode': 'stacktrace',
755757
'name': ex.name,
756758
'message': ex.message,
757759
'url': document.location.href,
758-
'stack': stack,
759-
'useragent': navigator.userAgent
760+
'stack': stack
760761
};
761762
}
762763

@@ -863,12 +864,10 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
863864
}
864865

865866
return {
866-
'mode': 'multiline',
867867
'name': ex.name,
868868
'message': lines[0],
869869
'url': document.location.href,
870-
'stack': stack,
871-
'useragent': navigator.userAgent
870+
'stack': stack
872871
};
873872
}
874873

@@ -996,12 +995,10 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
996995
}
997996

998997
var result = {
999-
'mode': 'callers',
1000998
'name': ex.name,
1001999
'message': ex.message,
10021000
'url': document.location.href,
1003-
'stack': stack,
1004-
'useragent': navigator.userAgent
1001+
'stack': stack
10051002
};
10061003
augmentStackTraceWithInitialElement(result, ex.sourceURL || ex.fileName, ex.line || ex.lineNumber, ex.message || ex.description);
10071004
return result;
@@ -1063,9 +1060,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10631060
}
10641061
}
10651062

1066-
return {
1067-
'mode': 'failed'
1068-
};
1063+
return {};
10691064
}
10701065

10711066
/**
@@ -1120,7 +1115,7 @@ var _Raven = window.Raven,
11201115
* @this {Raven}
11211116
*/
11221117
var Raven = {
1123-
VERSION: '1.1.10',
1118+
VERSION: '1.1.11',
11241119

11251120
// Expose TraceKit to the Raven namespace
11261121
TraceKit: TraceKit,

0 commit comments

Comments
 (0)