DbException class

Typed exceptions thrown by every dartapi_db driver.

All database errors surface as a DbException subclass, so application code can map them to HTTP responses without parsing driver messages:

try {
  await db.insert('users', {'email': dto.email, ...});
} on UniqueViolationException {
  throw const ApiException(409, 'Email already registered');
} on DbConnectionException {
  throw const ApiException(503, 'Database unavailable');
}

The original driver exception is preserved in cause for logging and debugging.

Implemented types
Implementers

Constructors

DbException(String message, {Object? cause})
const

Properties

cause Object?
The underlying driver exception, when available.
final
hashCode int
The hash code for this object.
no setterinherited
message String
Human-readable description of what failed.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited