From de49101c1598f1ac4a9f23d215f4cf1bf5d34e19 Mon Sep 17 00:00:00 2001 From: Scott Wadden Date: Wed, 11 Oct 2023 12:26:55 -0300 Subject: [PATCH] End unit json with a newline. Don't crash if we can't find the source of an exception. --- src/controllers/script_controllers/scripting.nim | 13 ++++++++----- src/models/serializers.nim | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/controllers/script_controllers/scripting.nim b/src/controllers/script_controllers/scripting.nim index b1a31d18..3b62356a 100644 --- a/src/controllers/script_controllers/scripting.nim +++ b/src/controllers/script_controllers/scripting.nim @@ -56,11 +56,14 @@ proc init_interpreter*[T](self: Worker, _: T) {.gcsafe.} = else: "???" - if file_name.get_file_info != ctx.file_name.get_file_info: - (file_name, info) = extract_file_info msg - # msg = msg.replace(re"unhandled exception:.*\) Error\: ", "") - #else: - # msg = msg.replace(re"(?ms);.*", "") + if file_exists(file_name): + if file_name.get_file_info != ctx.file_name.get_file_info: + (file_name, info) = extract_file_info msg + # msg = msg.replace(re"unhandled exception:.*\) Error\: ", "") + # else: + # msg = msg.replace(re"(?ms);.*", "") + else: + error "File not found handling error", file_name var loc = \"{file_name}({int info.line},{int info.col})" error "vm error", msg, file = ctx.file_name diff --git a/src/models/serializers.nim b/src/models/serializers.nim index 2779a29b..84dc87be 100644 --- a/src/models/serializers.nim +++ b/src/models/serializers.nim @@ -136,6 +136,7 @@ proc `$`(self: Unit): string = }} }} + """ proc save*(unit: Unit) =