Skip to content

Commit

Permalink
Apply error-handling patch
Browse files Browse the repository at this point in the history
  • Loading branch information
aughr committed Dec 19, 2013
1 parent 105b266 commit c5c7d36
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion angular-mocks.js
Expand Up @@ -2084,6 +2084,20 @@ angular.mock.clearDataCache = function() {
*
* @param {...Function} fns any number of functions which will be injected using the injector.
*/



var ErrorAddingDeclarationLocationStack = function(e, errorForStack) {
this.message = e.message;
this.name = e.name;
if (e.line) this.line = e.line;
if (e.sourceId) this.sourceId = e.sourceId;
if (e.stack && errorForStack)
this.stack = e.stack + '\n' + errorForStack.stack;
if (e.stackArray) this.stackArray = e.stackArray;
};
ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString;

window.inject = angular.mock.inject = function() {
var blockFns = Array.prototype.slice.call(arguments, 0);
var errorForStack = new Error('Declaration Location');
Expand All @@ -2104,7 +2118,10 @@ angular.mock.clearDataCache = function() {
injector.invoke(blockFns[i] || angular.noop, this);
/* jshint +W040 */
} catch (e) {
if(e.stack && errorForStack) e.stack += '\n' + errorForStack.stack;
/* e.stack += '\n' + errorForStack.stack; */
if (e.stack && errorForStack) {
throw new ErrorAddingDeclarationLocationStack(e, errorForStack);
}
throw e;
} finally {
errorForStack = null;
Expand Down

0 comments on commit c5c7d36

Please sign in to comment.