mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 16:06:08 +02:00
Improve stack trace error handling.
This commit is contained in:
@@ -123,13 +123,29 @@ internal sealed class RuntimeInformation
|
|||||||
{
|
{
|
||||||
if (!Stop)
|
if (!Stop)
|
||||||
{
|
{
|
||||||
Line line = Lines[Math.Min(LineNumber, Lines.Count - 1)];
|
if (Lines.Count == 0)
|
||||||
WriteLine($"{Environment.NewLine}[{(IsTask ? $"Task {TaskId}" : "The process")} was terminated at line {line.LineNumber + 1} in the file \"{line.FileName}\" with the message: {message}]", true);
|
{
|
||||||
|
WriteLine($"{Environment.NewLine}[{(IsTask ? $"Task {TaskId}" : "The process")} was terminated with the message: {message}]", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Line line = Lines[Math.Min(LineNumber, Lines.Count - 1)];
|
||||||
|
WriteLine($"{Environment.NewLine}[{(IsTask ? $"Task {TaskId}" : "The process")} was terminated at line {line.LineNumber + 1} in the file \"{line.FileName}\" with the message: {message}]", true);
|
||||||
|
}
|
||||||
|
|
||||||
while (FunctionCallStack.Count > 0)
|
while (FunctionCallStack.Count > 0)
|
||||||
{
|
{
|
||||||
int stackLineNumber = FunctionCallStack.Pop().CallerLine;
|
int stackLineNumber = FunctionCallStack.Pop().CallerLine;
|
||||||
Line stackLine = (ParentRuntimeInformation?.Lines ?? Lines)[stackLineNumber];
|
List<Line> targetLines = ParentRuntimeInformation?.Lines ?? Lines;
|
||||||
WriteLine($" at line {stackLine.LineNumber + 1} in the file \"{stackLine.FileName}\"", true);
|
if (stackLineNumber >= 0 && stackLineNumber < targetLines.Count)
|
||||||
|
{
|
||||||
|
Line stackLine = targetLines[stackLineNumber];
|
||||||
|
WriteLine($" at line {stackLine.LineNumber + 1} in the file \"{stackLine.FileName}\"", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteLine(" at unknown location (source not available)", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stop = true;
|
Stop = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user