diff --git a/Classes/Errors.cs b/Classes/Errors.cs index 4be484d..225d76e 100644 --- a/Classes/Errors.cs +++ b/Classes/Errors.cs @@ -1,14 +1,15 @@ using ezrSquared.General; +using static ezrSquared.Constants.constants; using System; namespace ezrSquared.Errors { public abstract class error { - public string name; - public string details; - public position startPos; - public position endPos; + internal string name; + internal string details; + internal position startPos; + internal position endPos; public error(string name, string details, position startPos, position endPos) { @@ -52,12 +53,12 @@ public class overflowError : error public class runtimeError : error { - public context context; + private context context; public runtimeError(position startPos, position endPos, string tag, string details, context context) : base(tag, details, startPos, endPos) { this.context = context; } public override string asString() { return $"{generateTraceback()}(runtime error) : {details} -> tag '{name}'\n\n{stringWithUnderline(startPos.text, startPos, endPos)}"; } - private string generateTraceback() + internal string generateTraceback() { string result = ""; position? pos = startPos; @@ -73,4 +74,12 @@ private string generateTraceback() return $"Traceback - most recent call last:\n{result}"; } } + + public class runtimeRunError : runtimeError + { + private string runError; + public runtimeRunError(position startPos, position endPos, string details, string runError, context context) : base(startPos, endPos, RT_RUN, details, context) { this.runError = runError; } + + public override string asString() { return $"{generateTraceback()}(runtime error) : {details} -> tag '{name}'\n\n{stringWithUnderline(startPos.text, startPos, endPos)}\n\n{runError}"; } + } } \ No newline at end of file diff --git a/Classes/Values.cs b/Classes/Values.cs index 333ed7c..a9d648a 100644 --- a/Classes/Values.cs +++ b/Classes/Values.cs @@ -2272,7 +2272,7 @@ private runtimeResult _run(context context) error? error = run(Path.GetFileName(path), script, runtimeContext, out item? _); if (error != null) - return result.failure(new runtimeError(startPos, endPos, RT_RUN, $"Failed to execute script \"{path}\"\n\n{error.asString()}", context)); + return result.failure(new runtimeRunError(startPos, endPos, $"Failed to execute script \"{path}\"", error.asString(), context)); return result.success(new nothing()); } diff --git a/Constants.cs b/Constants.cs index 8bfaf31..e96e76f 100644 --- a/Constants.cs +++ b/Constants.cs @@ -4,7 +4,7 @@ namespace ezrSquared.Constants { public static class constants { - public const string VERSION = "prerelease-1.3.1.0.0"; + public const string VERSION = "prerelease-1.3.2.0.0"; public const string VERSION_DATE = "14.02.2023"; public static readonly string[] KEYWORDS = { "item", "and", "or", "invert", "if", "else", "do", "count", "from", "as", "to", "step", "while", "function", "special", "with", "end", "return", "skip", "stop", "try", "error", "in", "object", "global", "include" }; diff --git a/README.md b/README.md index ee5da54..41736eb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ I just need to finish the documentation! If you find any bugs, report them [here ### Released **Check the [GitHub Commits](https://github.com/Uralstech/ezrSquared/commits) for all changes in source code** +* **prerelease-1.3.2.0.0** - [15-02-23] + * New runtimeRunError error class! + * **prerelease-1.3.1.0.0** - [14-02-23] * Fixed a count loop error message * Better error message for else if statements diff --git a/ezr.cs b/ezr.cs index 499f3cf..1d9c0b9 100644 --- a/ezr.cs +++ b/ezr.cs @@ -3381,7 +3381,7 @@ private runtimeResult visit_includeNode(includeNode node, context context) } catch (Exception exception) { - return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n{exception.Message}", context)); + return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", exception.Message, context)); } } else @@ -3398,11 +3398,11 @@ private runtimeResult visit_includeNode(includeNode node, context context) token[] tokens = new lexer(file, script).compileTokens(out error? error); if (error != null) - return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n\n{error.asString()}", context)); + return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", error.asString(), context)); parseResult parseResult = new parser(tokens).parse(); if (parseResult.error != null) - return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n\n{parseResult.error.asString()}", context)); + return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", parseResult.error.asString(), context)); value = result.register(new @class(formattedFileName, null, parseResult.node, new string[0]).setPosition(node.startPos, node.endPos).setContext(context).execute(new item[0])); if (result.shouldReturn()) return result;