Skip to content

Commit

Permalink
WIP: LBT improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 authored and tobiasso85 committed Jun 15, 2020
1 parent 8531260 commit d9ce20b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/lbt/analyzer/SmartTemplateAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TemplateComponentAnalyzer {
log.verbose("No manifest found for '%s', skipping analysis", resource.name);
}
} catch (err) {
log.error("an error occurred while analyzing template app %s (ignored)", resource.name, err);
log.error("an error occurred while analyzing template app %s (ignored)", resource.name, err.stack);
}

return info;
Expand Down
2 changes: 1 addition & 1 deletion lib/lbt/analyzer/XMLTemplateAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class XMLTemplateAnalyzer {
try {
requireContext = JSTokenizer.parseJS(coreRequire);
} catch (e) {
log.error("Ignoring core:require: Attribute can't be parsed on Node ", node.$ns.local);
log.error("Ignoring core:require: Attribute can't be parsed on Node %s", node.$ns.local);
log.error(coreRequire);
}
if ( requireContext ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/lbt/bundle/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class BundleBuilder {
try {
fileContent = JSON.stringify( JSON.parse( fileContent) );
} catch (e) {
log.error(e);
log.error("error while parsing JSON file %s", module, e.stack);
}
}
outW.write(makeStringLiteral(fileContent));
Expand Down
2 changes: 1 addition & 1 deletion lib/lbt/resources/ResourcePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function determineDependencyInfo(resource, rawInfo, pool) {
jsAnalyzer.analyze(ast, resource.name, info);
new XMLCompositeAnalyzer(pool).analyze(ast, resource.name, info);
} catch (error) {
log.error("failed to parse or analyze %s:", resource.name, error);
log.error("failed to parse or analyze %s:", resource.name, error.stack);
}
if ( rawInfo ) {
info.rawModule = true;
Expand Down
29 changes: 29 additions & 0 deletions test/lib/lbt/analyzer/XMLTemplateAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,32 @@ test("_analyzeViewRootNode: process node", async (t) => {
t.deepEqual(stubAddDependency.getCall(1).args[0], "myResourceBundleName.properties",
"addDependency should be called with the dependency name");
});

test("_analyzeCoreRequire: Catches error when attribute can't be parsed", async (t) => {
const analyzer = new XMLTemplateAnalyzer();
analyzer.info = {
addImplicitDependency: function() {},
addDependency: function() {}
};
const stubAddImplicitDependency = sinon.spy(analyzer.info, "addImplicitDependency");
const stubAddDependency = sinon.spy(analyzer.info, "addDependency");

const node = {
$: {
"core:require": {
name: "core:require",
prefix: "core",
local: "require",
uri: "sap.ui.core",
value: "{= '{Handler: \\'' + ${action>handlerModule} + '\\'}'}"
}
},
$ns: {
local: "Button"
}
};
await analyzer._analyzeCoreRequire(node);

t.is(stubAddImplicitDependency.callCount, 0, "addImplicitDependency was never called");
t.is(stubAddDependency.callCount, 0, "addDependency was never called");
});

0 comments on commit d9ce20b

Please sign in to comment.