SqlError

Classes > Nimblesite.Sql.Model > SqlError

Represents an error that occurred during SQL parsing or generation

public sealed record SqlError : IEquatable<SqlError>

Constructors

SqlError

public SqlError(string Message, Exception? Exception = null, SourcePosition? Position = null, string? Source = null)

Represents an error that occurred during SQL parsing or generation

Parameter Type Description
Message String
Exception Exception
Position SourcePosition
Source String

Properties

Message

public string Message { get; init; }

Exception

public Exception? Exception { get; init; }

Position

public SourcePosition? Position { get; init; }

Source

public string? Source { get; init; }

ErrorCode

public int? ErrorCode { get; init; }

The error code (if available)

InnerException

public Exception? InnerException { get; init; }

The inner exception (if available)

FormattedMessage

public string FormattedMessage { get; }

Gets a formatted error message with position information for VSCode

DetailedMessage

public string DetailedMessage { get; }

Gets a detailed error message with source context

Methods

Create(string)

public static SqlError Create(string message)

Creates a new SqlError with the specified message

Parameters:

Name Type Description
message String The error message

Returns: SqlError - A new SqlError instance

Create(string, int)

public static SqlError Create(string message, int errorCode)

Creates a new SqlError with the specified message and error code

Parameters:

Name Type Description
message String The error message
errorCode Int32 The error code

Returns: SqlError - A new SqlError instance

WithPosition(string, int, int, string?)

public static SqlError WithPosition(string message, int line, int column, string? source = null)

Creates a SqlError with position information

Parameters:

Name Type Description
message String The error message
line Int32 The line number (1-based)
column Int32 The column number (0-based)
source String The source text that caused the error

Returns: SqlError - A SqlError with position information

WithDetailedPosition(string, int, int, int, int, string?)

public static SqlError WithDetailedPosition(string message, int line, int column, int startIndex, int stopIndex, string? source = null)

Creates a SqlError with position information from ANTLR token

Parameters:

Name Type Description
message String The error message
line Int32 The line number (1-based)
column Int32 The column number (0-based)
startIndex Int32 The start index in the source
stopIndex Int32 The stop index in the source
source String The source text that caused the error

Returns: SqlError - A SqlError with detailed position information

FromException(Exception?, SourcePosition?)

public static SqlError FromException(Exception? exception, SourcePosition? position = null)

Creates a SqlError from an exception

Parameters:

Name Type Description
exception Exception The exception that occurred
position SourcePosition Optional position information

Returns: SqlError - A SqlError from the exception

Deconstruct(out string, out Exception?)

public void Deconstruct(out string message, out Exception? exception)

Deconstruct method for simple message and exception extraction

Parameters:

Name Type Description
message String The error message
exception Exception The exception, if any