From cc0b3cdc12060a85c90cef6d5215eba432e0d1aa Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 24 Apr 2017 15:58:46 -0400 Subject: [PATCH] niti: all fatal errors are catchable, not just aborts Signed-off-by: Jean Privat --- src/interpreter/naive_interpreter.nit | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 430af89..66afa45 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -821,6 +821,11 @@ redef class ANode # `v` is used to know if a colored message is displayed or not fun fatal(v: NaiveInterpreter, message: String) do + # Abort if there is a `catch` block + if v.catch_count > 0 then + abort + end + if v.modelbuilder.toolcontext.opt_no_color.value == true then sys.stderr.write("Runtime error: {message} ({location.file.filename}:{location.line_start})\n") else @@ -1689,13 +1694,8 @@ end redef class AAbortExpr redef fun stmt(v) do - # Abort as asked if there is no `catch` bloc - if v.catch_count <= 0 then - fatal(v, "Aborted") - exit(1) - else - abort - end + fatal(v, "Aborted") + exit(1) end end -- 1.7.9.5