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