MySQL · Types · Errors
ArxException
Definition
- Namespace
ARX.SDK- Package
ARX.SDK
public class ArxException : ExceptionBase type of every error ARX.SDK reports, apart from ArgumentNullException for null arguments. Handle errors by Code, Category or IsTransient, which are the same in every provider; the native details (NativeCode, SqlState, InnerException) are kept for diagnostics. Messages contain codes and names, never attribute values.
Constructor
ArxException(ArxErrorCode code, string message, Exception? innerException = null)An ARX error with its code and a message for logs and developers.
Parameter Type Description codeArxErrorCodeThe ARX error code: its thousands digit is the category. messagestringA message for logs and developers. It names tables, columns and constraints, never values. innerExceptionException?= nullThe error that caused it, if any.
Properties
ArxErrorCode Code { get; }The stable ARX error code.
ArxErrorCategory Category { get; }The category of
Code.bool IsTransient { get; init; }True when repeating the whole operation can succeed (deadlocks, timeouts, connection drops).
string? Provider { get; init; }The provider that reported the error, for example "PostgreSql". Null for errors raised before any provider work.
string? EntityName { get; init; }The entity (table or collection) involved, when known.
string? AttributeName { get; init; }The attribute (column) involved, when known.
string? ConstraintName { get; init; }The constraint the database reported, when known.
string? NativeCode { get; init; }The provider's own error code, for example "23505", "2627", "E11000" or an AWS exception name.
string? SqlState { get; init; }The ISO SQLSTATE, when the database supplies one.
string? Detail { get; init; }The database's detail for the error, when it gives one (a routine's
RAISE ... USING DETAIL).string? Hint { get; init; }The database's hint for the error, when it gives one (a routine's
RAISE ... USING HINT).int? BatchNumber { get; }The 1-based number of the failed call within its batch scope; null for errors raised outside a scope. Set by the scope when the error passes through it.
Methods
static string FormatCode(ArxErrorCode code)The message prefix for a code, for example "ARX3001 UniqueViolation".
Parameter Type Description codeArxErrorCodeThe error code.
Usage
A line from a verified sample; the full, runnable code is on its page.
catch (ArxException error) when (error.Code == ArxErrorCode.SchemaMismatch)Load ids and keys from JSON and validate them at startup, scenario 3
Used in:
- Turn ARX error codes into messages for the userCreate
- Load ids and keys from JSON and validate them at startupCreate
- Set the service up for productionCreate
- Use columns named outside the name rule, through aliasesCreate
- Log every call through ILoggerCreate
- Catch a record that doesn't existUpdate
- Find rows by id, by key or by columnsUpdate
- Turn update errors into messagesUpdate
- Catch an SQL injection attempt on updateUpdate
- Create an order and update the stock, all or nothingUpdate
- Update many records in one callUpdateMultiple
- Reprice 20,000 products from a feedUpdateMultiple
- Stock counts in batches: one transaction, a failed batch skippedUpdateMultiple
- Delete by key, by compound key, by columnsDelete
- Find a record by id, key or columnsRetrieve
- Turn read errors into messagesRetrieveMultiple
- Paging in depth: the total is opt-in, ask once, load more, Top, seek pagingRetrieveMultiple
- Views in depth: computed criteria, links both ways, declared ids and lookups, column boundariesRetrieveMultiple
- Business errors raised by a procedureExecute
- Handle Execute errorsExecute
- The sample application