Skip to content

Commit

Permalink
Match: show better error message if template throws
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Nov 9, 2017
1 parent 233cf09 commit 996ed11
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/bemxjst/match.js
Expand Up @@ -153,6 +153,19 @@ Match.prototype.tryCatch = function(fn, ctx) {
return fn.call(ctx, ctx, ctx.ctx);
} catch (e) {
this.thrownError = e;
if (this.modeName) {
this.thrownError.ctx = ctx;
this.thrownError.name = 'BEMXJST ERROR';
var classBuilder = this.entity.bemxjst.classBuilder;

var cause = e.stack.split('\n')[1];
this.thrownError.message = 'Template error in mode ' +
this.modeName + ' in block ' +
classBuilder.build(ctx.ctx.block, ctx.ctx.elem) +
'\n ' + e.message + '\n';
this.thrownError.stack = this.thrownError.name + ': ' +
this.thrownError.message + ' ' + cause + '\n' + e.stack;
}
}
};

Expand Down

0 comments on commit 996ed11

Please sign in to comment.