FirestoreException class
The exception thrown by Firestore operations. errorCode says what went wrong.
Futures fail with it, and streams (snapshots()) deliver it to onError,
after which the stream is done. It extends FirebaseException, like the
exceptions of FlutterFire: plugin is cloud_firestore and code is the
string form of errorCode ('permission-denied'). message describes the
cause in words; it is meant for logs, not for program logic. Check
errorCode (or code) instead. Invalid arguments that the client detects
before sending anything are reported as an ArgumentError, not as a
FirestoreException.
Note that code is a String: compare errorCode with the
FirestoreErrorCode values.
firestore.collection('cities').snapshots().listen(
(QuerySnapshot<Map<String, Object?>> snapshot) => print(snapshot.size),
onError: (Object error) {
if (error is FirestoreException &&
error.errorCode == FirestoreErrorCode.permissionDenied) {
print('Listen rejected by the security rules');
}
},
);
- Implemented types
Constructors
- FirestoreException({required FirestoreErrorCode errorCode, required String message, Object? cause, StackTrace? stackTrace})
-
Creates an exception with an
errorCodeand amessage, optionally keeping thecauseand a stack trace.
Properties
- cause → Object?
-
The lower-level error that caused this one, if any.
final
- code → String
-
What went wrong, in kebab case, for example
not-found.finalinherited - errorCode → FirestoreErrorCode
-
The status code of this exception, the part to check in code.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
A description of what went wrong, for logs.
no setter
- plugin → String
-
The package that threw the exception, for example
cloud_firestore.finalinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackTrace → StackTrace?
-
The stack trace captured where the exception originated, if any.
finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
[cloud_firestore/<code>] <message>, the format of FlutterFire, on one line: the stack trace is left out.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited