Skip to content

Commit

Permalink
feat(decorators): log exception in process attributes and process con…
Browse files Browse the repository at this point in the history
…tent

Fixes #330
  • Loading branch information
EisenbergEffect committed Jul 6, 2016
1 parent b6630a9 commit a15773f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ export function useShadowDOM(targetOrOptions?): any {
export function processAttributes(processor: Function): any {
return function(t) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, t);
r.processAttributes = processor;
r.processAttributes = function(compiler, resources, node, attributes, elementInstruction) {
try {
processor(compiler, resources, node, attributes, elementInstruction);
} catch (error) {
LogManager.getLogger('templating').error(error);
}
};
};
}

Expand All @@ -166,7 +172,14 @@ function doNotProcessContent() { return false; }
export function processContent(processor: boolean | Function): any {
return function(t) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, t);
r.processContent = processor || doNotProcessContent;
r.processContent = processor ? function(compiler, resources, node, instruction) {
try {
return processor(compiler, resources, node, instruction);
} catch (error) {
LogManager.getLogger('templating').error(error);
return false;
}
} : doNotProcessContent;
};
}

Expand Down

0 comments on commit a15773f

Please sign in to comment.