source: server/lib/gutenbach/ipp/core/errors.py @ 793432f

no-cups
Last change on this file since 793432f was 793432f, checked in by Jessica B. Hamrick <jhamrick@…>, 12 years ago

Reorganization

  • Property mode set to 100644
File size: 4.5 KB
Line 
1from .constants import ErrorCodes
2
3class IPPException(Exception):
4    def __init__(self, message=""):
5        self.message = message
6
7    def __str__(self):
8        return self.message
9
10class IPPClientException(IPPException):
11    def update_response(self, response):
12        if hasattr(self, "ipp_error_code"):
13            response.operation_id = self.ipp_error_code
14        else:
15            response.operation_id = ErrorCodes.BAD_REQUEST
16
17class IPPServerException(IPPException):
18    def update_response(self, response):
19        if hasattr(self, "ipp_error_code"):
20            response.operation_id = self.ipp_error_code
21        else:
22            response.operation_id = ErrorCodes.INTERNAL_ERROR
23   
24### Client error codes
25
26class ClientErrorBadRequest(IPPClientException):
27    ipp_error_code = ErrorCodes.BAD_REQUEST
28
29class ClientErrorForbidden(IPPClientException):
30    ipp_error_code = ErrorCodes.FORBIDDEN
31
32class ClientErrorNotAuthenticated(IPPClientException):
33    ipp_error_code = ErrorCodes.NOT_AUTHENTICATED
34
35class ClientErrorNotAuthorized(IPPClientException):
36    ipp_error_code = ErrorCodes.NOT_AUTHORIZED
37
38class ClientErrorNotPossible(IPPClientException):
39    ipp_error_code = ErrorCodes.NOT_POSSIBLE
40
41class ClientErrorTimeout(IPPClientException):
42    ipp_error_code = ErrorCodes.TIMEOUT
43
44class ClientErrorNotFound(IPPClientException):
45    ipp_error_code = ErrorCodes.NOT_FOUND
46
47class ClientErrorGone(IPPClientException):
48    ipp_error_code = ErrorCodes.GONE
49
50class ClientErrorRequestEntity(IPPClientException):
51    ipp_error_code = ErrorCodes.REQUEST_ENTITY
52
53class ClientErrorRequestValue(IPPClientException):
54    ipp_error_code = ErrorCodes.REQUEST_VALUE
55
56class ClientErrorDocumentFormatNotSupported(IPPClientException):
57    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT
58
59class ClientErrorAttributes(IPPClientException):
60    ipp_error_code = ErrorCodes.ATTRIBUTES
61
62    def __init__(self, message, attrs):
63        self.message = message
64        self.bad_attrs = attrs
65
66    def update_response(self, response):
67        pass
68
69class ClientErrorUriSchemeNotSupported(IPPClientException):
70    ipp_error_code = ErrorCodes.URI_SCHEME
71
72class ClientErrorCharsetNotSupported(IPPClientException):
73    ipp_error_code = ErrorCodes.CHARSET
74
75class ClientErrorConflict(IPPClientException):
76    ipp_error_code = ErrorCodes.CONFLICT
77
78class ClientErrorCompressionNotSupported(IPPClientException):
79    ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED
80
81class ClientErrorCompressionError(IPPClientException):
82    ipp_error_code = ErrorCodes.COMPRESSION_ERROR
83
84class ClientErrorDocumentFormatError(IPPClientException):
85    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR
86
87class ClientErrorDocumentAccessError(IPPClientException):
88    ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR
89
90class ClientErrorAttributesNotSettable(IPPClientException):
91    ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE
92
93class ClientErrorIgnoredAllSubscriptions(IPPClientException):
94    ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS
95
96class ClientErrorTooManySubscriptions(IPPClientException):
97    ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS
98
99class ClientErrorIgnoredAllNotifications(IPPClientException):
100    ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS
101
102class ClientErrorPrintSupportFileNotFound(IPPClientException):
103    ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND
104
105### Server error codes
106
107class ServerErrorInternalError(IPPServerException):
108    ipp_error_code = ErrorCodes.INTERNAL_ERROR
109
110class ServerErrorOperationNotSupported(IPPServerException):
111    ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED
112
113class ServerErrorServiceUnavailable(IPPServerException):
114    ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE
115
116class ServerErrorVersionNotSupported(IPPServerException):
117    ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED
118
119class ServerErrorDeviceError(IPPServerException):
120    ipp_error_code = ErrorCodes.DEVICE_ERROR
121
122class ServerErrorTemporaryError(IPPServerException):
123    ipp_error_code = ErrorCodes.TEMPORARY_ERROR
124
125class ServerErrorNotAccepting(IPPServerException):
126    ipp_error_code = ErrorCodes.NOT_ACCEPTING
127
128class ServerErrorPrinterBusy(IPPServerException):
129    ipp_error_code = ErrorCodes.PRINTER_BUSY
130
131class ServerErrorErrorJobCancelled(IPPServerException):
132    ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED
133
134class ServerErrorMultipleJobsNotSupported(IPPServerException):
135    ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED
136
137class ServerErrorPrinterIsDeactivated(IPPServerException):
138    ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED
Note: See TracBrowser for help on using the repository browser.