Skip to main content
Version: 2025

SalSqlError

Namespace: PPJ.Runtime.Sql

Assembly: PPJ.Web.50 (5.0.0.0)

Represents a SQL failure with a provider error number, provider position, and optional SAL error-handler result.

public class SalSqlError : ApplicationException

The exception-wrapping constructor recognizes supported or configured provider exceptions, retains the original exception, reduces its error code to the low 16 bits, and caches its message. Constructors that receive an explicit error number preserve that number and do not populate the message cache.

Example:

var error = new PPJ.Runtime.Sql.SalSqlError(100, 0, "Unable to fetch the record.");
System.Diagnostics.Debug.WriteLine(error.Number + ": " + error.Message);
error.Return = false;
bool hasHandlerResult = error.HasReturnValue; // true

Constructors

Instance member SalSqlError(err, pos, message)

Initializes a SQL error with an explicit code, position, and message.

NameTypeDescription
errInt32The error number to preserve.
posInt32The provider-specific error position.
messageStringThe descriptive error message.

Instance member SalSqlError(err, pos, message, source)

Initializes a SQL error with explicit details and an underlying exception.

NameTypeDescription
errInt32The error number to preserve.
posInt32The provider-specific error position.
messageStringThe descriptive error message.
sourceExceptionThe underlying exception, or null.

Instance member SalSqlError(source)

Extracts SQL error details from a supported database exception and caches its message.

NameTypeDescription
sourceExceptionThe non-null provider exception to wrap.

Provider codes are masked to 16 bits. The source exception is rethrown when its type is neither recognized nor configured as a provider SQL exception.

Properties

Instance member HasReturnValue

Boolean: Gets whether a SQL handler has explicitly assigned Return.

Instance member Number

Int32: Gets the explicit error code or the low 16 bits of the wrapped provider error code.

Instance member Position

Int32: Gets the provider-specific error position, such as a SQL Server line number, or zero when none was extracted.

Instance member Return

Boolean: Gets or sets the SQL handler result; assigning any value also sets HasReturnValue to true.

Methods

Static member GetErrorText(errorCode)

Looks up a message previously cached for an error number.

ParameterTypeDescription
errorCodeInt32The error number to look up.

Returns: String. The cached message, or null if the code has not been recorded.

A missing entry also writes a SQL trace warning.

Static member SetErrorText(err, text)

Adds or replaces the message cached for an error number.

ParameterTypeDescription
errInt32The error number used as the cache key.
textStringThe message to store.