MongoDB

Error codes

Every ARX error code, what it means, whether it is safe to retry, and the MongoDB errors it comes from.

Handling errors

Every error an ARX call throws is an ArxException with a stable Code: the same number and name in every provider. Its message starts with it (ARX3001 UniqueViolation: …), and the thousands digit is its Category. Catch by code, by category, or by IsTransient to retry, always on the base class: catch (ArxException e) when (e.Code == ArxErrorCode.RecordNotFound). Some codes come as a subclass (ArxValidationException before the database, ArxDatabaseException from it), but not every one, so a catch of a subclass can miss an error. A misuse found while you build the schema catalog at startup (a table declared twice, a key of a table that isn't declared) is an ArgumentException, as .NET builders report one, and a null argument an ArgumentNullException. The Errors in practice guide covers retries, HTTP statuses and a first connection's errors. The database's own error stays on the exception: SqlState, and the driver's exception as InnerException.

ARX1xxx Validation

ARX refused the call before sending it: invalid input, a misused connection, transaction or batch scope, or a name that looks like SQL injection.

Code Meaning Retry From MongoDB
ARX1001InvalidArgument

Invalid input not covered by a more specific code.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1002MissingEntityName

The entity name is null or blank.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1003InvalidIdentifier

An entity or attribute name fails the identifier rules.

No
  • 52 a field name starting with '$' (DollarPrefixedFieldName)
  • 56 an empty field name in an update path (EmptyFieldName)
  • 57 a field name with a dot (DottedFieldName)
  • 73 an invalid collection or database name (InvalidNamespace)
ARX1004DuplicateAttribute

The same attribute appears more than once (names are case-insensitive).

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1005InvalidLookup

A lookup (ArxEntityReference) has no usable Id.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1006InvalidSelectionSet

A selection set value has no option set name.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1007UnsupportedValueType

An attribute value has a type the provider can't write.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1008InvalidConnection

The connection or transaction is of the wrong driver type, or the service has no connection string.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1009TransactionMismatch

The transaction belongs to a different connection.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1010TransactionCompleted

The transaction has already been committed, rolled back or disposed.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1011SelectionSetValueNotAllowed

A selection set value isn't allowed by its set in the catalog: not one of its options, of the wrong kind, a retired option, several values for a single-choice set, a duplicate, or a value the set's storage can't hold.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1012UnknownSelectionSet

A selection set value names a set that isn't in the catalog, or no catalog was supplied.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1013InvalidDateTimeValue

A date or time value that would be stored as something else than the caller meant: default(DateTime), default(DateTimeOffset) or default(DateOnly) (no real date: a database would store a sentinel or refuse it), or an array mixing UTC and Unspecified DateTime values.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1014BatchScopeBusy

A batch scope was called while another call on it was still running. A scope holds one connection, which runs one command at a time: await each call before the next.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1015TransactionAborted

A call or a commit on a transaction that an earlier failed call has aborted. The database has already discarded the transaction's work; it can only be rolled back.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1016IdNotDeclared

The entity's table isn't declared in the service's schema catalog, and the entity doesn't declare its own id column. A service with a catalog uses only what is declared: ARX doesn't guess an id column. A service created without a catalog reads the table's primary key instead (where the provider can), and raises TableNotResolvable when it can't.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1017SuspectedInjection

A name (entity, attribute, match column or type) contains SQL syntax: a quote, a statement separator, a comment marker, a bracket, an operator or an SQL keyword after a space. That is the shape of an SQL injection attempt, not of a typo, so it gets its own code to alert on. Refused before the database: nothing was sent. Values are never checked for this: they are always parameters, and any text is stored as typed.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1018NotPreloaded

The service is Strict and the call names a table or column that wasn't preloaded: refused before the database. Preload it, or turn Strict off.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX1019TableNotResolvable

A service without a schema catalog resolves each table from the database, and this table has no id the call can use: no primary key, a primary key of several columns, or one of a type ARX can't use as an id. Refused before anything is sent, only for a call that needs the id (Create, Retrieve, Update or Delete by id). Declare the table in a schema catalog (ArxIdColumn.NoIdColumn), or match by a key or columns.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX

ARX2xxx NotFound

The rows the call addressed weren't found as asked: none, several where one was required, or one at another version than the call carried (ARX2004). Nothing was changed.

Code Meaning Retry From MongoDB
ARX2002RecordNotFound

The record addressed by key doesn't exist.

No
  • ARX's check an update or delete whose documents weren't all found: checked in ARX's transaction, nothing changed
ARX2003MultipleRecordsMatched

An update or delete with RequireSingleRow found more than one row for an entity. Nothing was changed.

No
  • ARX's check an entity that matched several documents when one was required
ARX2004RecordChanged

The record was changed since it was read: an Update or Delete carried a version (optimistic concurrency) that isn't the record's any more. Nothing was changed: read it again, and apply the change to what is there now.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX

ARX3xxx Constraint

The database refused the change because of a rule: a unique key, a foreign key, NOT NULL, CHECK, or a routine's own error.

Code Meaning Retry From MongoDB
ARX3001UniqueViolation

A unique constraint or key was violated.

No
  • 11000 duplicate key in a unique index (_id or a unique index)
  • 11001 duplicate key (older form)
ARX3002ForeignKeyViolation

A referenced record is missing, or a record is still referenced.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX3003NotNullViolation

A required attribute has no value.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX3004CheckViolation

A check constraint or validation rule failed.

No
  • 121 the document fails the collection's validator ($jsonSchema)
ARX3005RaisedByDatabase

A routine the database runs (a procedure or function) refused the call on purpose (PostgreSQL RAISE EXCEPTION, SQL Server THROW, MySQL SIGNAL). On PostgreSQL: RAISE EXCEPTION (SQLSTATE P0001), an ASSERT or a state of the routine's own (USING ERRCODE = 'AX001'). The message is the routine's; SqlState, Detail and Hint are its own.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX

ARX4xxx Data

A value doesn't fit its column: out of range, too long, in the wrong format or of the wrong type.

Code Meaning Retry From MongoDB
ARX4001ValueOutOfRange

A number is outside the column's range.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX4002ValueTooLong

Text or binary data is longer than the column allows.

No
  • 10334 a document larger than 16 MB
  • 17280 an index key too large
  • 17419 a document larger than 16 MB after an update
  • 17420 a document larger than 16 MB after an update (older form)
  • driver a document over 16 MB, refused by the driver before sending
ARX4003InvalidValueFormat

A value can't be parsed for its column (for example invalid JSON, dates or encoding).

No
  • 2 a bad value in a command (BadValue)
  • 40 two update operators on the same path (ConflictingUpdateOperators)
  • 17287 a regular expression MongoDB can't compile
ARX4004DataTypeMismatch

A value's type doesn't fit the column.

No
  • 14 an operator applied to a field of the wrong type (TypeMismatch)
  • 28 an update path through a field that isn't a document (PathNotViable)
  • 16837 an update path that crosses a value that isn't a document

ARX5xxx Schema

A table or column doesn't exist, or a declaration in the schema catalog doesn't match the table.

Code Meaning Retry From MongoDB
ARX5001UndefinedEntity

The table or collection doesn't exist.

No
  • 26 the collection or namespace doesn't exist (NamespaceNotFound)
ARX5002UndefinedAttribute

The column doesn't exist or can't be written.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX
ARX5003SchemaMismatch

A declaration in the schema catalog doesn't match the table: the database returned an id of another type, or ValidateSchemaAsync found a difference. The exception says whether rows were stored.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

NoARX

ARX6xxx Permission

The database user isn't allowed to do it.

Code Meaning Retry From MongoDB
ARX6001PermissionDenied

The database user lacks the required permission.

No
  • 13 the user lacks a privilege (Unauthorized)
  • 18 authentication failed

ARX7xxx Transient

A temporary failure: a deadlock, a conflict, a timeout, throttling or a lost connection. Safe to retry the whole operation (IsTransient is true).

Code Meaning Retry From MongoDB
ARX7001Deadlock

The operation was chosen as a deadlock victim. Safe to retry.

No MongoDB error maps to it: ARX raises it itself, from its own checks (before the call, or from what the database returned).

Safe to retryARX
ARX7002SerializationFailure

The operation conflicted with a concurrent transaction. Safe to retry.

Safe to retry
  • 112 a write conflict with another transaction (WriteConflict)
  • 244 the transaction was aborted (TransactionAborted)
  • 251 the transaction was aborted on the server (NoSuchTransaction)
ARX7003Timeout

The command or a lock wait timed out. Safe to retry.

Safe to retry
  • 24 a lock wasn't granted in time (LockTimeout)
  • 50 the operation's time limit was exceeded (MaxTimeMSExpired)
  • 290 the transaction exceeded its lifetime limit (TransactionExceededLifetimeLimitSeconds)
ARX7004Throttled

The server is rate-limiting or out of connections. Safe to retry later.

Safe to retry
  • 202 the server's connection pool is exhausted (NetworkInterfaceExceededTimeLimit)
ARX7005ConnectionFailure

The database couldn't be reached, or the connection dropped. Safe to retry.

Safe to retry
  • 6 the host is unreachable
  • 7 the host wasn't found
  • 89 a network timeout
  • 91 the server is shutting down
  • 189 the primary stepped down
  • 9001 a socket exception
  • 10107 the server isn't the primary (NotWritablePrimary)
  • 11600 the server was interrupted at shutdown
  • 11602 the operation was interrupted by a step-down
  • 13435 the server isn't the primary and secondaryOk is false
  • driver the driver couldn't select a server (timeout) or the connection broke

ARX8xxx NotSupported

The provider can't do what was asked, and refuses it rather than ignoring part of it.

Code Meaning Retry From MongoDB
ARX8001NotSupported

The provider doesn't support the requested operation or feature.

No
  • 20 an illegal operation (IllegalOperation, for example a transaction on a standalone server)
  • 66 a change to an immutable field such as _id (ImmutableField)
  • 166 a write to a view (CommandNotSupportedOnView)
  • 263 an operation not allowed in a transaction (OperationNotSupportedInTransaction)
  • 292 a sort or group past the memory limit without allowDiskUse (QueryExceededMemoryLimitNoDiskUseAllowed)
  • 16819 a sort past the memory limit
  • 40324 an unknown pipeline stage
  • ARX a transaction, or a write of several documents, on a standalone server

ARX9xxx Provider

A database error ARX doesn't map; the exception keeps its native code and SQLSTATE.

Code Meaning Retry From MongoDB
ARX9001ProviderError

A native error the provider doesn't map; see NativeCode and SqlState.

No
  • any other SQLSTATE