KoolbaseConflictException class
Thrown when a write (insert, update, or upsert) is rejected because the
value would violate a collection's unique constraint — the server responds
with 409 Conflict and code unique_violation. Catch this to handle
duplicates, e.g. an email or username that's already taken.
field names the field that collided, when the server reports it
(details.field) — useful when a collection has more than one unique
constraint and you need to know which value clashed.
try {
await Koolbase.db.collection('users').insert({'email': email});
} on KoolbaseConflictException catch (e) {
showError('That ${e.field ?? 'value'} is already registered.');
}
- Inheritance
-
- Object
- KoolbaseException
- KoolbaseDataException
- KoolbaseConflictException
Constructors
- KoolbaseConflictException([String message = 'Value violates a unique constraint', String? field])
-
const
Properties
- code → String?
-
The server's stable error code, when it sent one. Prefer branching on the
exception type; this is for logging and for codes the SDK does not yet map.
finalinherited
- field → String?
-
The field that violated the unique constraint, when known.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
What went wrong, in words. From the server where it said something useful.
finalinherited
- 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