niti: all fatal errors are catchable, not just aborts
authorJean Privat <jean@pryen.org>
Mon, 24 Apr 2017 19:58:46 +0000 (15:58 -0400)
committerJean Privat <jean@pryen.org>
Tue, 25 Apr 2017 16:46:54 +0000 (12:46 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/interpreter/naive_interpreter.nit

index 430af89..66afa45 100644 (file)
@@ -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