Last active
January 31, 2018 03:35
-
-
Save geekKeen/dda49cce7695e299c7aa5557609aa84c to your computer and use it in GitHub Desktop.
异常处理 / 自定义异常
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JobLookupError(KeyError): | |
def __init__(self, job_id): | |
super(KeyError, self).__init__(u'No job by the id of %s was found' % job_id) | |
raise JobLookupError(job_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HTTPException(Exception): | |
code = None | |
description = None | |
def __init__(self, description=None, response=None): | |
Exception.__init__(self) | |
if description is not None: | |
self.description = description | |
self.response = response | |
class BadRequest(HTTPException): | |
code = 400 | |
description = '...' | |
class ClientDisconnected(BadRequest): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTTP 各状态码的含义