-
Notifications
You must be signed in to change notification settings - Fork 0
API Host TypedDocumentException
TDoc diagnostic exception
Namespace: AuroraScript.Runtime.Serialization. Kind: sealed class inheriting AuroraException. Applies to 4.0.0.
Back to .NET Host API Reference
TypedDocumentException represents TDoc syntax, type-binding, value-range, or a host writing-configuration error that cannot safely continue. Beyond the normal Message, it provides source, line/column, and data-path information for configuration UIs and logs.
This exception is thrown by TypedDocumentSerializer and AuroraTypedDocument; TDoc.parse and TDoc.stringify convert it to AuroraRuntimeException on the script side.
// Given a configured AuroraEngine named engine:
using System;
try
{
_ = TypedDocumentSerializer.Deserialize(
engine,
"Object { Int8Array bytes [0, 255] }");
}
catch (TypedDocumentException error)
{
Console.WriteLine($"{error.SourceName} {error.Line}:{error.Column} {error.DataPath}");
Console.WriteLine(error.Message);
}string SourceNameReturns the diagnostic source name. The direct text API defaults to "<tdoc>"; ReadFile automatically uses the file path as its source.
Parameters
None.
Returns
Source name.
Simple Example
Console.WriteLine(error.SourceName); // <tdoc>int LineReturns a one-based line number. It is greater than zero for syntax or binding errors from text; it can be 0 for an error discovered only while writing configuration.
Parameters
None.
Returns
One-based line number, or 0.
Simple Example
if (error.Line > 0)
{
Console.WriteLine($"Line {error.Line}");
}int ColumnReturns a one-based column number. Its behavior matches Line: writing-configuration errors can report 0.
Parameters
None.
Returns
One-based column number, or 0.
Simple Example
Console.WriteLine($"Column {error.Column}");string DataPathReturns a data path relative to the root value. The root is $, object properties use .name, and array elements use [index].
Parameters
None.
Returns
TDoc data path.
Simple Example
if (error.DataPath == "$.bytes[1]")
{
Console.WriteLine("The second byte is invalid.");
}Preserve SourceName, Line, Column, and DataPath when displaying Message, rather than showing only underlying exception text.
Do not retry CLR/CIL types through reflection or an alternate alias after catching this error; fix the host registration or document contract.
File, permission, encoding, and stream errors are not this type and should be handled as their corresponding .NET I/O exceptions.
AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License