firebase_admin/_utils.py
def handle_requests_error(error, message=None, code=None):
    """Constructs a ``FirebaseError`` from the given requests error.

    This method is agnostic of the remote service that produced the error, whether it is a GCP
    service or otherwise. Therefore, this method does not attempt to parse the error response in
    any way.

    Args:
        error: An error raised by the requests module while making an HTTP call.
        message: A message to be included in the resulting ``FirebaseError`` (optional). If not
            specified the string representation of the ``error`` argument is used as the message.
        code: A GCP error code that will be used to determine the resulting error type (optional).
            If not specified the HTTP status code on the error response is used to determine a
            suitable error code.

    Returns:
        FirebaseError: A ``FirebaseError`` that can be raised to the user code.
    """
    if isinstance(error, requests.exceptions.Timeout):
        return exceptions.DeadlineExceededError(
            message='Timed out while making an API call: {0}'.format(error),
            cause=error)
    if isinstance(error, requests.exceptions.ConnectionError):
        return exceptions.UnavailableError(
            message='Failed to establish a connection: {0}'.format(error),
            cause=error)
    if error.response is None:
        return exceptions.UnknownError(
            message='Unknown error while making a remote service call: {0}'.format(error),
            cause=error)

    if not code:
        code = _http_status_to_error_code(error.response.status_code)
    if not message:
        message = str(error)

    err_type = _error_code_to_exception_type(code)
    return err_type(message=message, cause=error, http_response=error.response)
Constructs a ``FirebaseError`` from the given requests error.

    This method is agnostic of the remote service that produced the error, whether it is a GCP
    service or otherwise. Therefore, this method does not attempt to parse the error response in
    any way.

    Args:
        error: An error raised by the requests module while making an HTTP call.
        message: A message to be included in the resulting ``FirebaseError`` (optional). If not
            specified the string representation of the ``error`` argument is used as the message.
        code: A GCP error code that will be used to determine the resulting error type (optional).
            If not specified the HTTP status code on the error response is used to determine a
            suitable error code.

    Returns:
        FirebaseError: A ``FirebaseError`` that can be raised to the user code.
    
Constructs a ``FirebaseError`` from the given requests error.
This method is agnostic of the remote service that produced the error, whether it is a GCP
service or otherwise. Therefore, this method does not attempt to parse the error response in
any way.
Constructs a ` ` FirebaseError ` ` from the given requests error . This method is agnostic of the remote service that produced the error whether it is a GCP service or otherwise . Therefore this method does not attempt to parse the error response in any way .
def handle_requests_error(error, message=None, code=None):
    if isinstance(error, requests.exceptions.Timeout):
        return exceptions.DeadlineExceededError(
            message='Timed out while making an API call: {0}'.format(error),
            cause=error)
    if isinstance(error, requests.exceptions.ConnectionError):
        return exceptions.UnavailableError(
            message='Failed to establish a connection: {0}'.format(error),
            cause=error)
    if error.response is None:
        return exceptions.UnknownError(
            message='Unknown error while making a remote service call: {0}'.format(error),
            cause=error)
    if not code:
        code = _http_status_to_error_code(error.response.status_code)
    if not message:
        message = str(error)
    err_type = _error_code_to_exception_type(code)
    return err_type(message=message, cause=error, http_response=error.response)
def handle_requests_error ( error , message = None , code = None ) : if isinstance ( error , requests . exceptions . Timeout ) : return exceptions . DeadlineExceededError ( message = 'Timed out while making an API call: {0}' . format ( error ) , cause = error ) if isinstance ( error , requests . exceptions . ConnectionError ) : return exceptions . UnavailableError ( message = 'Failed to establish a connection: {0}' . format ( error ) , cause = error ) if error . response is None : return exceptions . UnknownError ( message = 'Unknown error while making a remote service call: {0}' . format ( error ) , cause = error ) if not code : code = _http_status_to_error_code ( error . response . status_code ) if not message : message = str ( error ) err_type = _error_code_to_exception_type ( code ) return err_type ( message = message , cause = error , http_response = error . response )
Constructs a ``FirebaseError`` from the given requests error.
Constructs a ` ` FirebaseError ` ` from the given requests error .
"""Constructs a ``FirebaseError`` from the given requests error.

    This method is agnostic of the remote service that produced the error, whether it is a GCP
    service or otherwise. Therefore, this method does not attempt to parse the error response in
    any way.

    Args:
        error: An error raised by the requests module while making an HTTP call.
        message: A message to be included in the resulting ``FirebaseError`` (optional). If not
            specified the string representation of the ``error`` argument is used as the message.
        code: A GCP error code that will be used to determine the resulting error type (optional).
            If not specified the HTTP status code on the error response is used to determine a
            suitable error code.

    Returns:
        FirebaseError: A ``FirebaseError`` that can be raised to the user code.
    """
A ``FirebaseError`` that can be raised to the user code.
A ` ` FirebaseError ` ` that can be raised to the user code .
FirebaseError
error
An error raised by the requests module while making an HTTP call.
An error raised by the requests module while making an HTTP call .
message
A message to be included in the resulting ``FirebaseError`` (optional). If not
specified the string representation of the ``error`` argument is used as the message.
A message to be included in the resulting ` ` FirebaseError ` ` ( optional ) . If not specified the string representation of the ` ` error ` ` argument is used as the message .
code
A GCP error code that will be used to determine the resulting error type (optional).
If not specified the HTTP status code on the error response is used to determine a
suitable error code.
A GCP error code that will be used to determine the resulting error type ( optional ) . If not specified the HTTP status code on the error response is used to determine a suitable error code .