MongoDB · 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 exception) when (exception.Code == ArxErrorCode.RecordNotFound)Set the service up for production, scenario 3
Used in:
- Set the service up for productionCreate
- Use fields named outside the name rule, through aliasesCreate
- Log every call through ILoggerCreate
- Update one recordUpdate
- Choose how the documents are foundUpdate
- Catch an injection attemptUpdate
- Update many records in one callUpdateMultiple
- Choose how the documents are foundDelete
- The sample application