104 lines
2.6 KiB
Python
104 lines
2.6 KiB
Python
from rest_framework import status
|
|
from rest_framework.exceptions import APIException as _default_APIException
|
|
|
|
|
|
class APIException(_default_APIException):
|
|
|
|
status_code = status.HTTP_400_BAD_REQUEST
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'unknown',
|
|
'detail': 'Unknown error occurred',
|
|
}
|
|
|
|
|
|
class ArmaIndustrialFirewallException(APIException):
|
|
|
|
status_code = status.HTTP_400_BAD_REQUEST
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'unknown',
|
|
'detail': 'Unknown error occurred',
|
|
}
|
|
|
|
|
|
class InvalidCredentialException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'unauthorized',
|
|
'detail': 'Invalid credentials provided to connect to firewall',
|
|
}
|
|
|
|
|
|
class ConnectionException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'connection_error',
|
|
'detail': 'There was a problem connecting to the firewall',
|
|
}
|
|
|
|
|
|
class IncompatibilityVersionException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'incompatible',
|
|
'detail': 'The firewall version is incompatible with the current console version'
|
|
}
|
|
|
|
|
|
class InvalidRequestException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'warning',
|
|
'code': 'request_error',
|
|
'detail': 'Firewall was reconfigured and caused internal error. Auto FW health check initiated. Please try again'
|
|
}
|
|
|
|
|
|
class RemoteException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'remote_error',
|
|
'detail': 'Unknown error occurred. Auto FW health check initiated. Please try again'
|
|
}
|
|
|
|
|
|
class NoContentDispositionException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'no_content',
|
|
'detail': 'No content disposition during downloading file from ARMA IF'
|
|
}
|
|
|
|
|
|
class InvalidFileException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'invalid',
|
|
'detail': 'Invalid file uploaded'
|
|
}
|
|
|
|
|
|
class FailedUploadException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'failed',
|
|
'detail': 'Failed to upload file to firewall'
|
|
}
|
|
|
|
|
|
class InvalidResponseException(ArmaIndustrialFirewallException):
|
|
|
|
default_detail = {
|
|
'status': 'error',
|
|
'code': 'invalid_response',
|
|
'detail': 'Unable to read firewall response'
|
|
}
|
|
|