Skip to content
Snippets Groups Projects
Commit 28bd5ad0 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Throw Error exception rather than just logging errors

better traceability
parent d513362b
No related branches found
No related tags found
No related merge requests found
...@@ -18,8 +18,7 @@ function xjs_compile(filename) { ...@@ -18,8 +18,7 @@ function xjs_compile(filename) {
var file = new File(filename); var file = new File(filename);
if(!file.open("r",true,8192)) { if(!file.open("r",true,8192)) {
writeln("!ERROR " + file.error + " opening " + file.name); writeln("!ERROR " + file.error + " opening " + file.name);
log(LOG_ERR, "!ERROR " + file.error + " opening " + file.name); throw new Error(format("%d (%s)", file.error, strerror(file.error)) + " opening " + file.name);
exit();
} }
var text = file.readAll(8192); var text = file.readAll(8192);
file.close(); file.close();
...@@ -86,7 +85,7 @@ function xjs_compile(filename) { ...@@ -86,7 +85,7 @@ function xjs_compile(filename) {
f.write(script); f.write(script);
f.close(); f.close();
} else { } else {
log(LOG_ERR, "!ERROR " + f.error + " creating " + f.name); throw new Error(format("%d (%s)", f.error, strerror(f.error)) + " creating " + f.name);
} }
} }
return(ssjs_filename); return(ssjs_filename);
...@@ -96,8 +95,7 @@ function xjs_eval(filename, str) { ...@@ -96,8 +95,7 @@ function xjs_eval(filename, str) {
const ssjs = xjs_compile(filename); const ssjs = xjs_compile(filename);
const f = new File(filename + '.html'); const f = new File(filename + '.html');
if (!f.open('w+', false)) { if (!f.open('w+', false)) {
log(LOG_ERR, "!ERROR " + f.error + " creating " + f.name); throw new Error(format("%d (%s)", f.error, strerror(f.error)) + " creating " + f.name);
return '';
} }
function write(s) { function write(s) {
f.write(s); f.write(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment