Fix small issues, improve error handling and documentation
This commit is contained in:
@@ -2,34 +2,58 @@ class HTTPException(Exception):
|
||||
""" Base class for HTTP exceptions """
|
||||
|
||||
|
||||
class InvalidResponse(HTTPException):
|
||||
""" Response message cannot be parsed """
|
||||
class UnhandledHTTPCode(Exception):
|
||||
status_code: str
|
||||
headers: str
|
||||
cause: str
|
||||
|
||||
def __init(self, message):
|
||||
def __init__(self, status, headers, cause):
|
||||
self.status_code = status
|
||||
self.headers = headers
|
||||
self.cause = cause
|
||||
|
||||
|
||||
class InvalidResponse(HTTPException):
|
||||
"""
|
||||
Response message cannot be parsed
|
||||
"""
|
||||
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
|
||||
class InvalidStatusLine(HTTPException):
|
||||
""" Response status line is invalid """
|
||||
"""
|
||||
Response status line is invalid
|
||||
"""
|
||||
|
||||
def __init(self, line):
|
||||
def __init__(self, line):
|
||||
self.line = line
|
||||
|
||||
|
||||
class UnsupportedEncoding(HTTPException):
|
||||
""" Encoding not supported """
|
||||
"""
|
||||
Encoding not supported
|
||||
"""
|
||||
|
||||
def __init(self, enc_type, encoding):
|
||||
def __init__(self, enc_type, encoding):
|
||||
self.enc_type = enc_type
|
||||
self.encoding = encoding
|
||||
|
||||
class UnsupportedProtocol(HTTPException):
|
||||
"""
|
||||
Protocol is not supported
|
||||
"""
|
||||
def __init__(self, protocol):
|
||||
self.protocol = protocol
|
||||
|
||||
|
||||
class IncompleteResponse(HTTPException):
|
||||
def __init(self, cause):
|
||||
def __init__(self, cause):
|
||||
self.cause = cause
|
||||
|
||||
|
||||
class HTTPServerException(Exception):
|
||||
class HTTPServerException(HTTPException):
|
||||
""" Base class for HTTP Server exceptions """
|
||||
status_code: str
|
||||
message: str
|
||||
@@ -68,7 +92,7 @@ class MethodNotAllowed(HTTPServerException):
|
||||
status_code = 405
|
||||
message = "Method Not Allowed"
|
||||
|
||||
def __init(self, allowed_methods):
|
||||
def __init__(self, allowed_methods):
|
||||
self.allowed_methods = allowed_methods
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user