def relax_exception(e):
    if isinstance(e, httpclient.HTTPError):
        if e.code == 304:
            ce = NotModified(e)
        elif e.code == 400:
            ce = BadRequest(e)
        elif e.code == 404:
            ce = NotFound(e)
        elif e.code == 405:
            ce = MethodNotAllowed(e)
        elif e.code == 409:
            ce = Conflict(e)
        elif e.code == 412:
            ce = PreconditionFailed(e)
        elif e.code == 500:
            ce = InternalServerError(e)
        else:
            # other HTTP Error
            ce = CouchException(e)
    else:
        # unknown exception
        ce = e

    return ce
Convert HTTPError exception to a Couch specific exception, if possible,
dataset/ETHPy150Open nephics/tornado-couchdb/couch/couch.py/relax_exception