diff --git a/src/compile/antlr_proc.cs b/src/compile/antlr_proc.cs index 1426dac7..00ed1f3b 100644 --- a/src/compile/antlr_proc.cs +++ b/src/compile/antlr_proc.cs @@ -839,9 +839,13 @@ static void WrapError(ANTLR_Processor proc, Action action) { action(); } - catch(SymbolError err) + catch(Exception e) { - proc.errors.Add(err); + if(e is ICompileError ce) + proc.errors.Add(ce); + else + //NOTE: let's turn other exceptions into BuildErrors + proc.errors.Add(new BuildError(proc.module.file_path, e)); } } diff --git a/src/compile/error.cs b/src/compile/error.cs index 0588213b..5a942546 100644 --- a/src/compile/error.cs +++ b/src/compile/error.cs @@ -75,6 +75,8 @@ public SyntaxError(string file, SourceRange range, string msg) public class BuildError : Exception, ICompileError { + private const int MAX_EXCEPTION_STR_LEN = 1000; + public string text { get; } public string stack_trace { get { return StackTrace; } } public SourceRange range { get { return new SourceRange(); } } @@ -87,15 +89,13 @@ public BuildError(string file, string msg) this.file = file; } - private const int MAX_EXCEPTION_STACK_LEN = 700; - public BuildError(string file, Exception inner) : base(ErrorUtils.MakeMessage(file, new SourceRange(), inner.Message), inner) { - var stack = inner.StackTrace; - if(stack.Length > MAX_EXCEPTION_STACK_LEN) - stack = stack.Substring(0, MAX_EXCEPTION_STACK_LEN) + "..."; - this.text = inner.Message + stack; + var msg = inner.ToString(); //NOTE: this will include all inner exceptions stack traces as well + if(msg.Length > MAX_EXCEPTION_STR_LEN) + msg = msg.Substring(0, MAX_EXCEPTION_STR_LEN) + "..."; + this.text = msg; this.file = file; } }