Skip to content

Commit 8373c21

Browse files
authored
Added documentation for error codes (#339)
1 parent a0bc210 commit 8373c21

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

firebase_admin/exceptions.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,69 @@
1515
"""Firebase Exceptions module.
1616
1717
This module defines the base types for exceptions and the platform-wide error codes as outlined in
18-
https://cloud.google.com/apis/design/errors.
18+
https://cloud.google.com/apis/deesign/errors.
19+
20+
:class:`FirebaseError` is the parent class of all exceptions raised by the Admin SDK. It contains
21+
the ``code``, ``http_response`` and ``cause`` properties common to all Firebase exception types.
22+
Each exception also carries a message that outlines what went wrong. This can be logged for
23+
audit or debugging purposes.
24+
25+
When calling an Admin SDK API, developers may catch the parent ``FirebaseError`` and
26+
inspect its ``code`` to implement fine-grained error handling. Alternatively, developers may
27+
catch one or more subtypes of ``FirebaseError``. Under normal conditions, any given API may raise
28+
only a small subset of the available exception subtypes. However, the SDK also exposes rare error
29+
conditions like connection timeouts and other I/O errors as instances of ``FirebaseError``.
30+
Therefore it is always a good idea to have a handler specified for ``FirebaseError``, after all the
31+
subtype error handlers.
1932
"""
2033

2134

35+
#: Error code for ``InvalidArgumentError`` type.
2236
INVALID_ARGUMENT = 'INVALID_ARGUMENT'
37+
38+
#: Error code for ``FailedPreconditionError`` type.
2339
FAILED_PRECONDITION = 'FAILED_PRECONDITION'
40+
41+
#: Error code for ``OutOfRangeError`` type.
2442
OUT_OF_RANGE = 'OUT_OF_RANGE'
43+
44+
#: Error code for ``UnauthenticatedError`` type.
2545
UNAUTHENTICATED = 'UNAUTHENTICATED'
46+
47+
#: Error code for ``PermissionDeniedError`` type.
2648
PERMISSION_DENIED = 'PERMISSION_DENIED'
49+
50+
#: Error code for ``NotFoundError`` type.
2751
NOT_FOUND = 'NOT_FOUND'
52+
53+
#: Error code for ``ConflictError`` type.
2854
CONFLICT = 'CONFLICT'
55+
56+
#: Error code for ``AbortedError`` type.
2957
ABORTED = 'ABORTED'
58+
59+
#: Error code for ``AlreadyExistsError`` type.
3060
ALREADY_EXISTS = 'ALREADY_EXISTS'
61+
62+
#: Error code for ``ResourceExhaustedError`` type.
3163
RESOURCE_EXHAUSTED = 'RESOURCE_EXHAUSTED'
64+
65+
#: Error code for ``CancelledError`` type.
3266
CANCELLED = 'CANCELLED'
67+
68+
#: Error code for ``DataLossError`` type.
3369
DATA_LOSS = 'DATA_LOSS'
70+
71+
#: Error code for ``UnknownError`` type.
3472
UNKNOWN = 'UNKNOWN'
73+
74+
#: Error code for ``InternalError`` type.
3575
INTERNAL = 'INTERNAL'
76+
77+
#: Error code for ``UnavailableError`` type.
3678
UNAVAILABLE = 'UNAVAILABLE'
79+
80+
#: Error code for ``DeadlineExceededError`` type.
3781
DEADLINE_EXCEEDED = 'DEADLINE_EXCEEDED'
3882

3983

0 commit comments

Comments
 (0)