docs: def custom_except_hook(exc_info):
      """
      A custom excepthook to present python errors produced by the CLI.
      We don't want to show end users big scary stacktraces if they aren't python
      programmers, so slim it down to some basic info. We keep a "DEBUGMODE" env
      variable kicking around to let us turn on stacktraces if we ever need them.
  
      Additionally, does global suppression of EPIPE errors, which often occur
      when a python command is piped to a consumer like `head` which closes its
      input stream before python has sent all of its output.
      DANGER: There is a (small) risk that this will bite us if there are EPIPE
      errors produced within the Globus SDK. We should keep an eye on this
      possibility, as it may demand more sophisticated handling of EPIPE.
      Possible TODO item to reduce this risk: inspect the exception and only hide
      EPIPE if it comes from within the globus_cli package.
      """
      exception_type, exception, traceback = exc_info
  
      # check if we're in debug mode, and run the real excepthook if we are
      ctx = click.get_current_context()
      state = ctx.ensure_object(CommandState)
      if state.debug:
          sys.excepthook(exception_type, exception, traceback)
  
      # we're not in debug mode, do custom handling
      else:
  
          # if it's a click exception, re-raise as original -- Click's main
          # execution context will handle pretty-printing
          if isinstance(exception, click.ClickException):
              reraise(exception_type, exception, traceback)
  
          # catch any session errors to give helpful instructions
          # on how to use globus session update
          elif (
              isinstance(exception, exc.GlobusAPIError)
              and exception.raw_json
              and "authorization_parameters" in exception.raw_json
          ):
              session_hook(exception)
  
          # handle the Globus-raised errors with our special hooks
          # these will present the output (on stderr) as JSON
          elif isinstance(exception, exc.TransferAPIError):
              if exception.code == "ClientError.AuthenticationFailed":
                  authentication_hook(exception)
              else:
                  transferapi_hook(exception)
  
          elif isinstance(exception, exc.AuthAPIError):
              if exception.code == "UNAUTHORIZED":
                  authentication_hook(exception)
              # invalid_grant occurs when the users refresh tokens are not valid
              elif exception.message == "invalid_grant":
                  invalidrefresh_hook(exception)
              else:
                  authapi_hook(exception)
  
          elif isinstance(exception, exc.GlobusAPIError):
              globusapi_hook(exception)
  
          # specific checks fell through -- now check if it's any kind of
          # GlobusError
          elif isinstance(exception, exc.GlobusError):
              globus_generic_hook(exception)
  
          # not a GlobusError, not a ClickException -- something like ValueError
          # or NotImplementedError bubbled all the way up here: just print it
          # out, basically
          else:
              safeprint(u"{}: {}".format(exception_type.__name__, exception))
              sys.exit(1)