KoolbaseError class
A normalized SDK failure.
try {
await Koolbase.db.collection('orders').insert({'total': 42});
} catch (e) {
final err = KoolbaseError.from(e);
switch (err.code) {
case KoolbaseErrorCode.unauthorized:
await routeToSignIn(); // session already cleared by the SDK
case KoolbaseErrorCode.validation:
showFieldError(err.details?['field'] as String?);
case KoolbaseErrorCode.network:
showRetry(); // err.retryable is true
default:
showGenericFailure(); // never err.message — see below
}
log(err.message); // diagnostics go to the log
}
Constructors
-
KoolbaseError({required KoolbaseErrorCode code, required String message, Map<
String, Object?> ? details, String? rawCode}) -
const
- KoolbaseError.from(Object e)
-
Normalizes ANY throwable into a KoolbaseError.
factory
Properties
- code → KoolbaseErrorCode
-
What kind of failure this is. Branch on this.
final
-
details
→ Map<
String, Object?> ? -
Safe machine-readable context, where the failure carried any: the field
that failed validation, a lockout timestamp, a size limit. Null when the
failure carried none, which is most of the time.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
Developer-facing diagnostic information.
final
- rawCode → String?
-
The server's raw error code, when it sent one. For logging and for codes
the SDK does not yet map. Prefer code.
final
- retryable → bool
-
Whether trying the same thing again could plausibly succeed without the
user changing anything.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- userMessage → String?
-
A short message that is safe to show to people, where a generic one is
honest (network failures). null otherwise: show your own wording for
those. message is for developers.
no setter
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