kepconfig.error
error Exception classes raised by Kepconfig.
Includes KepError, KepURLError and KepHTTPError
1# ------------------------------------------------------------------------- 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved. 3# See License.txt in the project root for 4# license information. 5# -------------------------------------------------------------------------- 6 7 8r"""`error` Exception classes raised by Kepconfig. 9Includes KepError, KepURLError and KepHTTPError 10""" 11 12__all__ = ['KepError', 'KepURLError', 'KepHTTPError'] 13 14 15class KepError(Exception): 16 '''General Exception class for Kepconfig. 17 18 :param msg: General error message returned in string format. 19 ''' 20 def __init__(self, msg): 21 self.msg = msg 22 23 def __str__(self): 24 return 'KepError Error: %s' % (self.msg) 25 26class KepURLError(KepError): 27 '''Exception class raised by Kepconfig that derives responses from the urllib URLError exceptions. 28 29 :param url: full url path of the request that flagged a URLError exception 30 :param msg: reason parameter in URLError exception 31 ''' 32 def __init__(self, url=None, *args, **kwargs): 33 super().__init__(*args, **kwargs) 34 self.url = url 35 36 @property 37 def reason(self): 38 return self.msg 39 40 def __str__(self): 41 return '<urlopen error %s>' % self.reason 42 43class KepHTTPError(KepError): 44 '''Exception class raised by Kepconfig that derives responses from the urllib HTTPError 45 exceptions. This exception class is also a valid HTTP response instance. It behaves 46 this way because HTTP protocol errors are valid responses, with a status 47 code, headers, and a body. In some contexts, an application may want to 48 handle an exception like a regular response. 49 50 :param url: url parameter in HTTPError exception 51 :param code: HTTP response code parameter in HTTPError exception 52 :param hdrs: hdrs parameter in HTTPError exception 53 :param payload: string of HTTP response payload that flagged HTTPError exception 54 :param msg: msg parameter in HTTPError exception 55 ''' 56 def __init__(self, url=None, code=None, hdrs=None, payload=None, *args, **kwargs): 57 super().__init__(*args, **kwargs) 58 self.url = url 59 self.code = code 60 self.hdrs = hdrs 61 self.payload = payload 62 63 @property 64 def reason(self): 65 return self.msg 66 67 def __str__(self): 68 return 'HTTP Error %s: %s' % (self.code, self.msg)
class
KepError(builtins.Exception):
16class KepError(Exception): 17 '''General Exception class for Kepconfig. 18 19 :param msg: General error message returned in string format. 20 ''' 21 def __init__(self, msg): 22 self.msg = msg 23 24 def __str__(self): 25 return 'KepError Error: %s' % (self.msg)
General Exception class for Kepconfig.
Parameters
- msg: General error message returned in string format.
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
27class KepURLError(KepError): 28 '''Exception class raised by Kepconfig that derives responses from the urllib URLError exceptions. 29 30 :param url: full url path of the request that flagged a URLError exception 31 :param msg: reason parameter in URLError exception 32 ''' 33 def __init__(self, url=None, *args, **kwargs): 34 super().__init__(*args, **kwargs) 35 self.url = url 36 37 @property 38 def reason(self): 39 return self.msg 40 41 def __str__(self): 42 return '<urlopen error %s>' % self.reason
Exception class raised by Kepconfig that derives responses from the urllib URLError exceptions.
Parameters
- url: full url path of the request that flagged a URLError exception
- msg: reason parameter in URLError exception
44class KepHTTPError(KepError): 45 '''Exception class raised by Kepconfig that derives responses from the urllib HTTPError 46 exceptions. This exception class is also a valid HTTP response instance. It behaves 47 this way because HTTP protocol errors are valid responses, with a status 48 code, headers, and a body. In some contexts, an application may want to 49 handle an exception like a regular response. 50 51 :param url: url parameter in HTTPError exception 52 :param code: HTTP response code parameter in HTTPError exception 53 :param hdrs: hdrs parameter in HTTPError exception 54 :param payload: string of HTTP response payload that flagged HTTPError exception 55 :param msg: msg parameter in HTTPError exception 56 ''' 57 def __init__(self, url=None, code=None, hdrs=None, payload=None, *args, **kwargs): 58 super().__init__(*args, **kwargs) 59 self.url = url 60 self.code = code 61 self.hdrs = hdrs 62 self.payload = payload 63 64 @property 65 def reason(self): 66 return self.msg 67 68 def __str__(self): 69 return 'HTTP Error %s: %s' % (self.code, self.msg)
Exception class raised by Kepconfig that derives responses from the urllib HTTPError exceptions. This exception class is also a valid HTTP response instance. It behaves this way because HTTP protocol errors are valid responses, with a status code, headers, and a body. In some contexts, an application may want to handle an exception like a regular response.
Parameters
- url: url parameter in HTTPError exception
- code: HTTP response code parameter in HTTPError exception
- hdrs: hdrs parameter in HTTPError exception
- payload: string of HTTP response payload that flagged HTTPError exception
- msg: msg parameter in HTTPError exception