15 # |
15 # |
16 ## |
16 ## |
17 # @author Teemu Rytkonen |
17 # @author Teemu Rytkonen |
18 |
18 |
19 class ConeException(Exception): |
19 class ConeException(Exception): |
20 pass |
20 """ |
|
21 Base class for ConE exceptions. |
|
22 |
|
23 The attributes ``problem_desc`` and ``problem_lineno`` contain a description of |
|
24 the error and the line on which the error occurred, if available. |
|
25 The exception message itself may be composed of these two to make it more |
|
26 readable, but it may also just be the same as the description. |
|
27 |
|
28 @message: Exception message. |
|
29 @param problem_lineno: The line number for api.Problem conversion. Can be None to |
|
30 signify that the line number is not available. |
|
31 @param problem_desc: Error description for api.Problem conversion. If None, |
|
32 the exception message will be used here also. |
|
33 @param problem_type: Problem type for api.Problem conversion. If None, the |
|
34 class-level default will be used. |
|
35 """ |
|
36 |
|
37 #: Problem type for conversion to api.Problem. |
|
38 #: A default can be set on the exception class level, but it may |
|
39 #: also be set for individual exception instances. |
|
40 problem_type = None |
|
41 |
|
42 def __init__(self, message='', problem_lineno=None, problem_msg=None, problem_type=None): |
|
43 Exception.__init__(self, message) |
|
44 self.problem_lineno = problem_lineno |
|
45 self.problem_msg = problem_msg or message |
|
46 if problem_type is not None: |
|
47 self.problem_type = problem_type |
21 |
48 |
22 class NotSupportedException(ConeException): |
49 class NotSupportedException(ConeException): |
23 def __init__(self, message=""): |
50 def __init__(self, message=""): |
24 self.message = "Not supported! %s" % message |
51 self.message = "Not supported! %s" % message |
25 ConeException.__init__(self, self.message) |
52 ConeException.__init__(self, self.message) |
44 |
71 |
45 class ConePersistenceError(ConeException): |
72 class ConePersistenceError(ConeException): |
46 pass |
73 pass |
47 |
74 |
48 class ParseError(ConeException): |
75 class ParseError(ConeException): |
49 """ |
76 pass |
50 Exception raised when invalid data is attempted to be parsed. |
|
51 |
|
52 The attributes ``desc`` and ``lineno`` contain a description of |
|
53 the error and the line on which the error occurred, if available. |
|
54 The exception message itself may be composed of these two to make it more |
|
55 readable, but it may also just be the same as the description. |
|
56 |
|
57 @message: Exception message. |
|
58 @param lineno: The line number where the error occurred. Can be None to |
|
59 signify that the line number is not available. |
|
60 @param desc: Error description. If None, the exception message will be |
|
61 used here also. |
|
62 """ |
|
63 def __init__(self, message, lineno=None, desc=None): |
|
64 ConeException.__init__(self, message) |
|
65 self.lineno = lineno |
|
66 self.desc = desc or message |
|
67 |
77 |
68 class XmlParseError(ParseError): |
78 class XmlParseError(ParseError): |
69 pass |
79 problem_type = 'xml' |
|
80 |
|
81 class XmlSchemaValidationError(ParseError): |
|
82 problem_type = 'schema' |
|
83 |
|
84 class ConfmlParseError(ParseError): |
|
85 problem_type = 'model.confml' |
|
86 |
|
87 class ImplmlParseError(ParseError): |
|
88 problem_type = 'model.implml' |
70 |
89 |
71 class IncorrectClassError(ConeException): |
90 class IncorrectClassError(ConeException): |
72 pass |
91 pass |
73 |
92 |
74 class InvalidRef(ConeException): |
93 class InvalidRef(ConeException): |