Skip to content

Error Handling ​

Every failed SQL statement in DataVoContext.Execute returns a QueryResult with IsError = true, a human-readable message in Messages, and a stable ErrorCode from DataVoErrorCodes. Syntax errors also populate ErrorLine and ErrorColumn. Always branch on ErrorCode rather than message text.

csharp
using DataVo.Core.Contracts.Results;

QueryResult result = db.Execute(
    "INSERT INTO players (id, name, score) VALUES (1, 'Ada', 1200)")[0];

if (result.IsError && result.ErrorCode == DataVoErrorCodes.PrimaryKeyViolation)
{
    Console.WriteLine("Player 1 already exists.");
}

Error Surfaces by API ​

Every DML statement and bulk insert is all-or-nothing: if any row violates a constraint, nothing from that statement is written.

API LayerFailure SurfaceError Code Property
DataVoContext.Execute / PrepareQueryResult (IsError = true)result.ErrorCode, ErrorLine, ErrorColumn
Insert<T>, InsertTyped, InsertTypedBatch, BulkInsertConstraintViolationExceptionex.ErrorCode
DataVo.Data (ADO.NET / Dapper)DataVo.Data.DataVoExceptionex.ErrorCode, ex.Line, ex.Column
DataVo.EntityFrameworkCoreDataVoEfExceptionex.ErrorCode (propagated from the engine or EF bridge)
csharp
try
{
    cmd.ExecuteNonQuery();
}
catch (DataVo.Data.DataVoException ex) when (ex.ErrorCode == DataVoErrorCodes.Deadlock)
{
    // Retry transaction after deadlock victim selection
}

Error Code Catalog (DataVoErrorCodes) ​

Syntax & Input (DV1xxx) ​

CodeConstantMeaning
DV1001_SYNTAXSyntaxInvalid or incomplete SQL. Check ErrorLine and ErrorColumn.
DV1002_EMPTY_STATEMENTEmptyStatementThe input string contained no executable statement.

Binding & Catalog (DV2xxx) ​

CodeConstantMeaning
DV2001_NO_DATABASE_SELECTEDNoDatabaseSelectedNo active database; run USE <database> first.
DV2002_UNKNOWN_DATABASEUnknownDatabaseReferenced database does not exist (USE keeps the prior selection).
DV2003_UNKNOWN_TABLEUnknownTableTable does not exist in the active database.
DV2004_UNKNOWN_COLUMNUnknownColumnColumn does not exist on the target table.
DV2005_UNKNOWN_INDEXUnknownIndexIndex does not exist.
DV2006_AMBIGUOUS_COLUMNAmbiguousColumnUnqualified column matches multiple joined tables; qualify with table/alias.
DV2007_UNKNOWN_TABLE_ALIASUnknownTableAliasQualified reference names a table or alias not in the query.
DV2101_DATABASE_EXISTSDatabaseExistsDatabase already exists.
DV2102_TABLE_EXISTSTableExistsTable already exists.
DV2103_INDEX_EXISTSIndexExistsIndex already exists on the table.
DV2900_BINDINGBindingUncategorized binding error.
DV2901_CATALOGCatalogUncategorized catalog error.
DV2902_INDEXIndexUncategorized index error.

Constraints (DV3xxx) ​

CodeConstantMeaning
DV3001_PRIMARY_KEY_VIOLATIONPrimaryKeyViolationDuplicate primary key value.
DV3002_NULL_PRIMARY_KEYNullPrimaryKeyPrimary key column received NULL.
DV3003_UNIQUE_VIOLATIONUniqueViolationDuplicate value in a UNIQUE column.
DV3004_FOREIGN_KEY_VIOLATIONForeignKeyViolationMissing parent row or blocked parent delete.
DV3005_NOT_NULL_VIOLATIONNotNullViolationNOT NULL column received NULL.

Type & Evaluation (DV4xxx) ​

CodeConstantMeaning
DV4001_TYPE_MISMATCHTypeMismatchValue does not match column type (e.g., 'abc' for INT).
DV4002_VALUE_TOO_LONGValueTooLongString exceeds VARCHAR(n) length (values are never silently truncated).
DV4003_VALUE_COUNT_MISMATCHValueCountMismatchVALUES count does not match target column count.
DV4004_DIVISION_BY_ZERODivisionByZeroDivision by zero during expression evaluation.
DV4900_EVALUATIONEvaluationUncategorized expression evaluation error.

Transactions, Auth, Storage & Internal (DV5xxx–DV9xxx) ​

CodeConstantMeaning
DV5001_NO_ACTIVE_TRANSACTIONNoActiveTransactionCOMMIT or ROLLBACK called without an active BEGIN.
DV5002_TRANSACTION_ALREADY_ACTIVETransactionAlreadyActiveBEGIN called while a transaction is already active in the session.
DV5003_DEADLOCKDeadlockTransaction selected as deadlock victim; safe to retry.
DV6001_PERMISSION_DENIEDPermissionDeniedActive session lacks required privileges.
DV7001_DATABASE_IN_USEDatabaseInUseData directory is locked by another process or opened with incompatible settings.
DV7900_STORAGEStorageUncategorized storage I/O or engine failure.
DV9000_ERRORGeneralGeneral unclassified error.
DV9001_INTERNALInternalUnexpected internal failure; please file a bug report with the offending statement.

See Also ​