move instanceof to catch block

This commit is contained in:
Robert Muir 2016-05-26 15:03:13 -04:00
parent f037807117
commit 76ca4af561
1 changed files with 6 additions and 8 deletions

View File

@ -305,11 +305,10 @@ public class ScriptService extends AbstractComponent implements Closeable {
// for the inline case, then its anonymous: null.
String actualName = (type == ScriptType.INLINE) ? null : name;
compiledScript = new CompiledScript(type, name, lang, scriptEngineService.compile(actualName, code, params));
} catch (Exception exception) {
} catch (ScriptException good) {
// TODO: remove this try-catch completely, when all script engines have good exceptions!
if (exception instanceof ScriptException) {
throw exception; // its already good!
}
throw good; // its already good
} catch (Exception exception) {
throw new GeneralScriptException("Failed to compile " + type + " script [" + name + "] using lang [" + lang + "]", exception);
}
@ -367,11 +366,10 @@ public class ScriptService extends AbstractComponent implements Closeable {
"skipping compile of script [{}], lang [{}] as all scripted operations are disabled for indexed scripts",
template.getScript(), scriptLang);
}
} catch (Exception e) {
} catch (ScriptException good) {
// TODO: remove this when all script engines have good exceptions!
if (e instanceof ScriptException) {
throw e; // its already good!
}
throw good; // its already good!
} catch (Exception e) {
throw new IllegalArgumentException("Unable to parse [" + template.getScript() +
"] lang [" + scriptLang + "]", e);
}