Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Improve error message for missing script
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jun 2, 2015
1 parent a44ad08 commit 03e54ad
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions zanata-war/src/main/java/org/zanata/util/CommonMarkRenderer.java
Expand Up @@ -53,6 +53,10 @@ public class CommonMarkRenderer {
private static final String RESOURCE_NAME = "META-INF/resources/webjars/" +
SCRIPT_NAME;

public CommonMarkRenderer() {
log.info("Using commonmark.js version {}", VER);
}

// ScriptEngine is expensive, but not really threadsafe (even in Rhino).
// However, they are quite large, so it's probably not worth keeping
// one for every thread. Instead, we keep one around, and synchronise
Expand Down Expand Up @@ -115,8 +119,13 @@ private Invocable getInvocable() {
}

private InputStream getScriptAsStream() {
return getClass().getClassLoader().getResourceAsStream(
RESOURCE_NAME);
InputStream stream =
getClass().getClassLoader().getResourceAsStream(
RESOURCE_NAME);
if (stream == null) {
throw new RuntimeException("Script "+ RESOURCE_NAME + " not found");
}
return stream;
}

private ScriptEngine newEngine() {
Expand Down

0 comments on commit 03e54ad

Please sign in to comment.