File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,15 @@ class Chef {
5555 progress = await recipe . execute ( this . dish , progress ) ;
5656 } catch ( err ) {
5757 log . error ( err ) ;
58+
59+ let displayStr ;
60+ if ( "displayStr" in err ) {
61+ displayStr = err . displayStr ;
62+ } else {
63+ displayStr = err . toString ( ) ;
64+ }
5865 error = {
59- displayStr : err . displayStr ,
66+ displayStr : displayStr ,
6067 } ;
6168 progress = err . progress ;
6269 }
Original file line number Diff line number Diff line change 55 */
66
77import Utils from "./Utils.mjs" ;
8- import { fromHex } from "./lib/Hex.mjs" ;
8+ import { fromHex } from "./lib/Hex.mjs" ;
9+ import OperationError from "./errors/OperationError.mjs" ;
910
1011/**
1112 * The arguments to operations.
@@ -119,7 +120,9 @@ class Ingredient {
119120 number = parseFloat ( data ) ;
120121 if ( isNaN ( number ) ) {
121122 const sample = Utils . truncate ( data . toString ( ) , 10 ) ;
122- throw "Invalid ingredient value. Not a number: " + sample ;
123+ throw new OperationError (
124+ "Invalid ingredient value. Not a number: " + sample ,
125+ ) ;
123126 }
124127 return number ;
125128 default :
Original file line number Diff line number Diff line change 55 */
66
77import Dish from "./Dish.mjs" ;
8+ import OperationError from "./errors/OperationError.mjs" ;
89import Ingredient from "./Ingredient.mjs" ;
910
1011/**
@@ -223,7 +224,11 @@ class Operation {
223224 */
224225 set ingValues ( ingValues ) {
225226 ingValues . forEach ( ( val , i ) => {
226- this . _ingList [ i ] . value = val ;
227+ try {
228+ this . _ingList [ i ] . value = val ;
229+ } catch ( err ) {
230+ throw new OperationError ( `Failed to set value of ingredient '${ this . _ingList [ i ] . name } ': ${ err } ` ) ;
231+ }
227232 } ) ;
228233 }
229234
Original file line number Diff line number Diff line change @@ -70,11 +70,15 @@ class Recipe {
7070 if ( o instanceof Operation ) {
7171 return o ;
7272 } else {
73- const op = new modules [ o . module ] [ o . name ] ( ) ;
74- op . ingValues = o . ingValues ;
75- op . breakpoint = o . breakpoint ;
76- op . disabled = o . disabled ;
77- return op ;
73+ try {
74+ const op = new modules [ o . module ] [ o . name ] ( ) ;
75+ op . ingValues = o . ingValues ;
76+ op . breakpoint = o . breakpoint ;
77+ op . disabled = o . disabled ;
78+ return op ;
79+ } catch ( err ) {
80+ throw new Error ( `Failed to hydrate operation '${ o . name } ': ${ err } ` ) ;
81+ }
7882 }
7983 } ) ;
8084 }
You can’t perform that action at this time.
0 commit comments