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.
- C#
- VB.NET
public class SalSqlError : ApplicationException
Public Class SalSqlError
Inherits 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
SalSqlError(err, pos, message)
Initializes a SQL error with an explicit code, position, and message.
| Name | Type | Description |
|---|---|---|
| err | Int32 | The error number to preserve. |
| pos | Int32 | The provider-specific error position. |
| message | String | The descriptive error message. |
SalSqlError(err, pos, message, source)
Initializes a SQL error with explicit details and an underlying exception.
| Name | Type | Description |
|---|---|---|
| err | Int32 | The error number to preserve. |
| pos | Int32 | The provider-specific error position. |
| message | String | The descriptive error message. |
| source | Exception | The underlying exception, or null. |
SalSqlError(source)
Extracts SQL error details from a supported database exception and caches its message.
| Name | Type | Description |
|---|---|---|
| source | Exception | The 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
HasReturnValue
Boolean: Gets whether a SQL handler has explicitly assigned Return.
Number
Int32: Gets the explicit error code or the low 16 bits of the wrapped provider error code.
Position
Int32: Gets the provider-specific error position, such as a SQL Server line number, or zero when none was extracted.
Return
Boolean: Gets or sets the SQL handler result; assigning any value also sets HasReturnValue to true.
Methods
GetErrorText(errorCode)
Looks up a message previously cached for an error number.
| Parameter | Type | Description |
|---|---|---|
| errorCode | Int32 | The 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.
SetErrorText(err, text)
Adds or replaces the message cached for an error number.
| Parameter | Type | Description |
|---|---|---|
| err | Int32 | The error number used as the cache key. |
| text | String | The message to store. |