All Globus SDK errors inherit from GlobusError, and all SDK error classes are importable from globus_sdk.

You can therefore capture all errors thrown by the SDK by looking for GlobusError, as in:

import logging
from globus_sdk import TransferClient, GlobusError

    tc = TransferClient()
    # search with no parameters will throw an exception
    eps = tc.endpoint_search()
except exc.GlobusError:
    logging.exception("Globus Error!")

In most cases, it’s best to look for specific subclasses of GlobusError. For example, to write code which is distinguishes between network failures and unexpected API conditions, you’ll want to look for NetworkError and GlobusAPIError:

import logging
from globus_sdk import (TransferClient,
                        GlobusError, GlobusAPIError, NetworkError)

    tc = TransferClient()

    eps = tc.endpoint_search(filter_fulltext="myendpointsearch")

    for ep in eps:

except GlobusAPIError as e:
    # Error response from the REST service, check the code and message for
    # details.
    logging.error(("Got a Globus API Error\n"
                   "Error Code: {}\n"
                   "Error Message: {}").format(e.code, e.message))
    raise e
except NetworkError:
    logging.error(("Network Failure. "
                   "Possibly a firewall or connectivity issue"))
except GlobusError:
    logging.exception("Totally unexpected GlobusError!")

Of course, if you want to learn more information about the response, you should inspect it more than this. Malformed calls to Globus SDK methods may raise standard python exceptions (ValueError, etc.), but for correct usage, all errors will be instances of GlobusError.

Error Classes

class globus_sdk.exc.GlobusError[source]

Bases: exceptions.Exception

Root of the Globus Exception hierarchy. Stub class.

class globus_sdk.exc.GlobusAPIError(r, *args, **kw)[source]

Bases: globus_sdk.exc.GlobusError

Wraps errors returned by a REST API.

  • http_status – HTTP status code (int)
  • code – Error code from the API (str), or “Error” for unclassified errors
  • message – Error message from the API. In general, this will be more useful to developers, but there may be cases where it’s suitable for display to end users.

Get the verbatim error message received from a Globus API, interpreted as a JSON string and evaluated as a dict

If the body cannot be loaded as JSON, this is None


Get the verbatim error message receved from a Globus API as a string

class globus_sdk.exc.NetworkError(msg, exc, *args, **kw)[source]

Bases: globus_sdk.exc.GlobusError

Error communicating with the REST API server.

Holds onto original exception data, but also takes a message to explain potentially confusing or inconsistent exceptions passed to us

class globus_sdk.exc.GlobusConnectionError(msg, exc, *args, **kw)[source]

Bases: globus_sdk.exc.NetworkError

A connection error occured while making a REST request.

class globus_sdk.exc.GlobusTimeoutError(msg, exc, *args, **kw)[source]

Bases: globus_sdk.exc.NetworkError

The REST request timed out.