File: exceptions.py

package info (click to toggle)
python-softlayer 6.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,508 kB
  • sloc: python: 57,195; makefile: 133; xml: 97; sh: 59
file content (99 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
    SoftLayer.exceptions
    ~~~~~~~~~~~~~~~~~~~~
    Exceptions used throughout the library

    :license: MIT, see LICENSE for more details.
"""
# pylint: disable=C0103


class SoftLayerError(Exception):
    """The base SoftLayer error."""


class Unauthenticated(SoftLayerError):
    """Unauthenticated."""


class IAMError(SoftLayerError):
    """Errors from iam.cloud.ibm.com"""

    def __init__(self, fault_code, fault_string, url=None):
        SoftLayerError.__init__(self, fault_string)
        self.faultCode = fault_code
        self.faultString = fault_string
        self.url = url

    def __repr__(self):
        return f"{self.url} ({self.faultCode}): {self.faultString}"

    def __str__(self):
        return f"{self.url} ({self.faultCode}): {self.faultString}"


class SoftLayerAPIError(SoftLayerError):
    """SoftLayerAPIError is an exception raised during API errors.

    Provides faultCode and faultString properties.
    """

    def __init__(self, fault_code, fault_string, *args):
        SoftLayerError.__init__(self, fault_string, *args)
        self.faultCode = fault_code
        self.reason = self.faultString = fault_string

    def __repr__(self):
        return '<%s(%s): %s>' % (self.__class__.__name__, self.faultCode, self.faultString)

    def __str__(self):
        return '%s(%s): %s' % (self.__class__.__name__, self.faultCode, self.faultString)


class ParseError(SoftLayerAPIError):
    """Parse Error."""


class ServerError(SoftLayerAPIError):
    """Server Error."""


class ApplicationError(SoftLayerAPIError):
    """Application Error."""


class RemoteSystemError(SoftLayerAPIError):
    """System Error."""


class TransportError(SoftLayerAPIError):
    """Transport Error."""


# XMLRPC Errors
class NotWellFormed(ParseError):
    """Request was not well formed."""


class UnsupportedEncoding(ParseError):
    """Encoding not supported."""


class InvalidCharacter(ParseError):
    """There was an invalid character."""


class SpecViolation(ServerError):
    """There was a spec violation."""


class MethodNotFound(SoftLayerAPIError):
    """Method name not found."""


class InvalidMethodParameters(SoftLayerAPIError):
    """Invalid method paramters."""


class InternalError(ServerError):
    """Internal Server Error."""