From 0dbc7d4fd19093b1a1e44664503c14e987db2189 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Mon, 30 Apr 2018 17:25:13 +0000 Subject: [PATCH] Tidied up OperationError code. --- src/core/Recipe.mjs | 11 +++++------ src/core/errors/OperationError.mjs | 12 ++++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/Recipe.mjs b/src/core/Recipe.mjs index 808a97b0..22c4463b 100755 --- a/src/core/Recipe.mjs +++ b/src/core/Recipe.mjs @@ -7,8 +7,8 @@ // import Operation from "./Operation.js"; import OpModules from "./config/modules/OpModules"; import OperationConfig from "./config/OperationConfig.json"; -import log from "loglevel"; import OperationError from "./errors/OperationError"; +import log from "loglevel"; /** * The Recipe controls a list of Operations and the Dish they operate on. @@ -176,7 +176,7 @@ class Recipe { dish.set(output, op.outputType); } } catch (err) { - // print expected errors in output pane + // Return expected errors as output if (err instanceof OperationError) { dish.set(err.message, "string"); return i; @@ -185,11 +185,10 @@ class Recipe { e.progress = i; if (e.fileName) { - e.displayStr = op.name + " - " + e.name + " in " + - e.fileName + " on line " + e.lineNumber + - ".

Message: " + (e.displayStr || e.message); + e.displayStr = `${op.name} - ${e.name} in ${e.fileName} on line ` + + `${e.lineNumber}.

Message: ${e.displayStr || e.message}`; } else { - e.displayStr = op.name + " - " + (e.displayStr || e.message); + e.displayStr = `${op.name} - ${e.displayStr || e.message}`; } throw e; diff --git a/src/core/errors/OperationError.mjs b/src/core/errors/OperationError.mjs index a87f3978..71405718 100644 --- a/src/core/errors/OperationError.mjs +++ b/src/core/errors/OperationError.mjs @@ -1,12 +1,16 @@ /** - * Create custom error type for handling operation input errors. - * i.e. where the operation can handle the error and print a - * message to the screen. + * Custom error type for handling operation input errors. + * i.e. where the operation can handle the error and print a message to the screen. + * + * @author d98762625 [d98762625@gmail.com] + * @copyright Crown Copyright 2018 + * @license Apache-2.0 */ class OperationError extends Error { /** * Standard error constructor. Adds no new behaviour. - * @param args standard error args + * + * @param args - Standard error args */ constructor(...args) { super(...args);