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