With previous versions of DataObjects.Net v4.x there was no way to handle database errors in one fashion. All ADO.NET exceptions (like SqlException for SQL Server or NpgsqlException for PostgreSQL) were passed to user code simply wrapped in StorageException. These times have gone. Upcoming DataObjects.Net v4.2 will support a nice new feature. We called it "unified storage level exceptions". As the name suggests all ADO.NET errors are now unified.
Here are the exceptions you could expect. They are naturally grouped by cause of error.
StorageException is the base exception for all storage errors.
ConstraintViolationExceptionis the base exception for SQL constraint violations.CheckConstraintViolationExceptiondenotes violation of acheckornot nullconstraint.ReferentialContraintViolationExceptiondenotes a violation of aforeign keyconstraint.UniqueConstraintViolationExceptiondenotes a violation of auniqueorprimary keyconstraint.
ReprocessableExceptionis the base exception forTransactionSerializationFailureExceptionandDeadlockExceptionDeadlockExceptionwill surely be used very often, it’s thrown when you got into a deadlock with other transaction working on the same data.TransactionSerializationFailureExceptiondenotes any concurrent access problem except deadlock.
General errors:
ConnectionErrorExceptionis thrown when there is something wrong with the database connection.SyntaxErrorExceptionis thrown when RDBMS was not satisfied with the supplied SQL query :-)OperationTimeoutExceptionis thrown when server spent too much time executing your query and ADO.NET client decided it can not wait any longer :-) This exception probably denotes a live lock.
There are other descendants of StorageException but they are not related with database communication and are not shown here.
No comments:
Post a Comment