diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js index 441cbbb1..2c6f5e9e 100755 --- a/src/js/config/OperationConfig.js +++ b/src/js/config/OperationConfig.js @@ -62,6 +62,11 @@ var OperationConfig = { name: "Merge delimiter", type: "binary_short_string", value: FlowControl.MERGE_DELIM + }, + { + name: "Ignore errors", + type: "boolean", + value: FlowControl.FORK_IGNORE_ERRORS } ] }, diff --git a/src/js/core/FlowControl.js b/src/js/core/FlowControl.js index 2730eed6..35801c16 100755 --- a/src/js/core/FlowControl.js +++ b/src/js/core/FlowControl.js @@ -19,6 +19,11 @@ var FlowControl = { * @default */ MERGE_DELIM: "\\n", + /** + * @constant + * @default + */ + FORK_IGNORE_ERRORS: false, /** * Fork operation. @@ -30,15 +35,16 @@ var FlowControl = { * @returns {Object} The updated state of the recipe. */ run_fork: function(state) { - var op_list = state.op_list, - input_type = op_list[state.progress].input_type, - output_type = op_list[state.progress].output_type, - input = state.dish.get(input_type), - ings = op_list[state.progress].get_ing_values(), - split_delim = ings[0], - merge_delim = ings[1], - sub_op_list = [], - inputs = []; + var op_list = state.op_list, + input_type = op_list[state.progress].input_type, + output_type = op_list[state.progress].output_type, + input = state.dish.get(input_type), + ings = op_list[state.progress].get_ing_values(), + split_delim = ings[0], + merge_delim = ings[1], + ignore_errors = ings[2], + sub_op_list = [], + inputs = []; if (input) inputs = input.split(split_delim); @@ -55,14 +61,21 @@ var FlowControl = { var recipe = new Recipe(), output = "", - progress; + progress = 0; recipe.add_operations(sub_op_list); // Run recipe over each tranche for (i = 0; i < inputs.length; i++) { var dish = new Dish(inputs[i], input_type); - progress = recipe.execute(dish, 0); + try { + progress = recipe.execute(dish, 0); + } catch(err) { + if (!ignore_errors) { + throw err; + } + progress = err.progress + 1; + } output += dish.get(output_type) + merge_delim; } diff --git a/src/js/core/Recipe.js b/src/js/core/Recipe.js index b93d7560..b5173bcb 100755 --- a/src/js/core/Recipe.js +++ b/src/js/core/Recipe.js @@ -177,13 +177,12 @@ Recipe.prototype.execute = function(dish, start_from) { var e = typeof err == "string" ? { message: err } : err; e.progress = i; - e.display_str = op.name + " - "; if (e.fileName) { - e.display_str += e.name + " in " + e.fileName + - " on line " + e.lineNumber + - ".

Message: " + e.message; + e.display_str = op.name + " - " + e.name + " in " + + e.fileName + " on line " + e.lineNumber + + ".

Message: " + (e.display_str || e.message); } else { - e.display_str += e.message; + e.display_str = op.name + " - " + (e.display_str || e.message); } throw e;