mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 01:06:16 -04:00
Improve handling of errors in operations.
Remove unused dependencies.
This commit is contained in:
parent
689d08416b
commit
f72749304d
5 changed files with 38 additions and 42 deletions
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import Utils from "../core/Utils";
|
||||
import {toBase64} from "../core/lib/Base64";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
import Utils from "../core/Utils";
|
||||
import {toBase64} from "../core/lib/Base64";
|
||||
|
||||
self.maxWorkers = 4;
|
||||
self.maxTabs = 1;
|
||||
|
|
|
@ -172,7 +172,6 @@ class OutputWaiter {
|
|||
|
||||
if (status !== "error") {
|
||||
delete this.outputs[inputNum].error;
|
||||
delete this.outputs[inputNum].progress;
|
||||
}
|
||||
|
||||
this.set(inputNum);
|
||||
|
@ -189,6 +188,17 @@ class OutputWaiter {
|
|||
this.outputs[inputNum].bakeId = bakeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the stored progress value for the output in the output array
|
||||
*
|
||||
* @param {number} progress
|
||||
* @param {number} inputNum
|
||||
*/
|
||||
updateOutputProgress(progress, inputNum) {
|
||||
if (this.getOutput(inputNum) === -1) return;
|
||||
this.outputs[inputNum].progress = progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an output from the output array.
|
||||
*
|
||||
|
@ -240,7 +250,11 @@ class OutputWaiter {
|
|||
this.manager.controls.hideStaleIndicator();
|
||||
}
|
||||
|
||||
this.manager.recipe.updateBreakpointIndicator(false);
|
||||
if (output.progress !== undefined) {
|
||||
this.manager.recipe.updateBreakpointIndicator(output.progress);
|
||||
} else {
|
||||
this.manager.recipe.updateBreakpointIndicator(false);
|
||||
}
|
||||
|
||||
document.getElementById("show-file-overlay").style.display = "none";
|
||||
|
||||
|
@ -263,8 +277,6 @@ class OutputWaiter {
|
|||
|
||||
outputText.value = output.error;
|
||||
outputHtml.innerHTML = "";
|
||||
|
||||
this.manager.recipe.updateBreakpointIndicator(output.progress);
|
||||
} else if (output.status === "baked" || output.status === "inactive") {
|
||||
this.displayTabInfo(inputNum);
|
||||
this.toggleLoader(false);
|
||||
|
@ -1122,7 +1134,6 @@ class OutputWaiter {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handler for copy click events.
|
||||
* Copies the output to the clipboard
|
||||
|
|
|
@ -142,11 +142,18 @@ class WorkerWaiter {
|
|||
switch (r.action) {
|
||||
case "bakeComplete":
|
||||
log.debug(`Bake ${inputNum} complete.`);
|
||||
this.updateOutput(r.data, r.data.inputNum, r.data.bakeId);
|
||||
this.workerFinished(currentWorker);
|
||||
|
||||
if (r.data.error) {
|
||||
this.app.handleError(r.data.error);
|
||||
this.manager.output.updateOutputError(r.data.result, inputNum, r.data.progress);
|
||||
this.workerFinished(currentWorker);
|
||||
} else {
|
||||
this.updateOutput(r.data, r.data.inputNum, r.data.bakeId, r.data.progress);
|
||||
this.workerFinished(currentWorker);
|
||||
}
|
||||
break;
|
||||
case "bakeError":
|
||||
if (!r.data.hasOwnProperty("progress")) this.app.handleError(r.data.error);
|
||||
this.app.handleError(r.data.error);
|
||||
this.manager.output.updateOutputError(r.data.error, inputNum, r.data.progress);
|
||||
this.app.progress = r.data.progress;
|
||||
this.workerFinished(currentWorker);
|
||||
|
@ -190,9 +197,11 @@ class WorkerWaiter {
|
|||
* @param {Object} data
|
||||
* @param {number} inputNum
|
||||
* @param {number} bakeId
|
||||
* @param {number} progress
|
||||
*/
|
||||
updateOutput(data, inputNum, bakeId) {
|
||||
updateOutput(data, inputNum, bakeId, progress) {
|
||||
this.manager.output.updateOutputBakeId(bakeId, inputNum);
|
||||
this.manager.output.updateOutputProgress(progress, inputNum);
|
||||
this.manager.output.updateOutputValue(data, inputNum);
|
||||
this.manager.output.updateOutputStatus("baked", inputNum);
|
||||
// this.manager.recipe.updateBreakpointIndicator(this.app.progress);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue