mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Add OperationError error type and use for errors to be printed to the output panel
This commit is contained in:
parent
a8aa1bc5e8
commit
cc20ad9567
10 changed files with 82 additions and 69 deletions
|
@ -8,6 +8,7 @@
|
|||
import OpModules from "./config/modules/OpModules";
|
||||
import OperationConfig from "./config/OperationConfig.json";
|
||||
import log from "loglevel";
|
||||
import OperationError from "./errors/OperationError";
|
||||
|
||||
/**
|
||||
* The Recipe controls a list of Operations and the Dish they operate on.
|
||||
|
@ -175,18 +176,24 @@ class Recipe {
|
|||
dish.set(output, op.outputType);
|
||||
}
|
||||
} catch (err) {
|
||||
const e = typeof err == "string" ? { message: err } : err;
|
||||
|
||||
e.progress = i;
|
||||
if (e.fileName) {
|
||||
e.displayStr = op.name + " - " + e.name + " in " +
|
||||
e.fileName + " on line " + e.lineNumber +
|
||||
".<br><br>Message: " + (e.displayStr || e.message);
|
||||
// print expected errors in output pane
|
||||
if (err instanceof OperationError) {
|
||||
dish.set(err.message, "string");
|
||||
return i;
|
||||
} else {
|
||||
e.displayStr = op.name + " - " + (e.displayStr || e.message);
|
||||
}
|
||||
const e = typeof err == "string" ? { message: err } : err;
|
||||
|
||||
throw e;
|
||||
e.progress = i;
|
||||
if (e.fileName) {
|
||||
e.displayStr = op.name + " - " + e.name + " in " +
|
||||
e.fileName + " on line " + e.lineNumber +
|
||||
".<br><br>Message: " + (e.displayStr || e.message);
|
||||
} else {
|
||||
e.displayStr = op.name + " - " + (e.displayStr || e.message);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue