def translate_boto_error(error, message=None, set_cause=True, *args, **kwargs):
    """Convert a ClientError exception into a Python one.

    Parameters
    ----------

    error : botocore.exceptions.ClientError
        The exception returned by the boto API.
    message : str
        An error message to use for the returned exception. If not given, the
        error message returned by the server is used instead.
    set_cause : bool
        Whether to set the __cause__ attribute to the previous exception if the
        exception is translated.
    *args, **kwargs :
        Additional arguments to pass to the exception constructor, after the
        error message. Useful for passing the filename arguments to ``IOError``.

    Returns
    -------

    An instantiated exception ready to be thrown. If the error code isn't
    recognized, an IOError with the original error message is returned.
    """
    error_response = getattr(error, "response", None)

    if error_response is None:
        # non-http error, or response is None:
        return error
    code = error_response["Error"].get("Code")
    if (
        code == "PreconditionFailed"
        and error_response["Error"].get("Condition", "") == "If-None-Match"
    ):
        constructor = FileExistsError
    else:
        constructor = ERROR_CODE_TO_EXCEPTION.get(code)
    if constructor:
        if not message:
            message = error_response["Error"].get("Message", str(error))
        custom_exc = constructor(message, *args, **kwargs)
    else:
        # No match found, wrap this in an IOError with the appropriate message.
        custom_exc = IOError(errno.EIO, message or str(error), *args)

    if set_cause:
        custom_exc.__cause__ = error
    return custom_exc
Convert a ClientError exception into a Python one.

Parameters
----------

error : botocore.exceptions.ClientError
The exception returned by the boto API.
message : str
An error message to use for the returned exception. If not given, the
error message returned by the server is used instead.
set_cause : bool
Whether to set the __cause__ attribute to the previous exception if the
exception is translated.
*args, **kwargs :
Additional arguments to pass to the exception constructor, after the
error message. Useful for passing the filename arguments to ``IOError``.

Returns
-------

An instantiated exception ready to be thrown. If the error code isn't
recognized, an IOError with the original error message is returned.
s3fs/errors.py