django_socio_grpc.exceptions
This module contains all the exceptions that can be raised by DSG.
It builds on top of DRF APIException and adds gRPC status codes to the exceptions. https://www.django-rest-framework.org/api-guide/exceptions/#apiexception
Module Contents
Functions
Get the gRPC status code and details from the exception.
|
Data
Map HTTP status codes to gRPC status codes. Allows the handling of DRF exceptions. DSG must return gRPC status codes to the client. |
API
- exception django_socio_grpc.exceptions.ProtobufGenerationException(app_name=None, model_name=None, detail=None)
Bases:
ExceptionAn exception class for handling errors related to protobuf generation within DSG. It can be raised with specific information about the app name, model name, and a detail message. Deprecated, only used in old generation method
Initialization
Initialize self. See help(type(self)) for accurate signature.
- default_detail
‘Unknown’
- __str__()
- django_socio_grpc.exceptions.LOGGING_LEVEL
None
- exception django_socio_grpc.exceptions.GRPCException(detail=None, code=None)
Bases:
rest_framework.exceptions.APIExceptionBase class for DSG exceptions. Subclasses should provide
.status_codeand.default_detailproperties. You can also set.logging_levelproperty to log the exception with theInitialization
Initialize self. See help(type(self)) for accurate signature.
- status_code: grpc.StatusCode
None
- logging_level: django_socio_grpc.exceptions.LOGGING_LEVEL
‘WARNING’
- exception django_socio_grpc.exceptions.Unauthenticated(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the UNAUTHENTICATED gRPC status code. It indicates that authentication credentials were not provided.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘not_authenticated’
- exception django_socio_grpc.exceptions.PermissionDenied(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the PERMISSION_DENIED gRPC status code. It indicates that the user does not have permission to perform a certain action.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘permission_denied’
- exception django_socio_grpc.exceptions.NotFound(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the NOT_FOUND gRPC status code. It indicates that the requested resource was not found.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘not_found’
- exception django_socio_grpc.exceptions.AlreadyExist(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the ALREADY_EXISTS gRPC status code. It indicates that the requested resource already exists.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘already_exist’
- exception django_socio_grpc.exceptions.InvalidArgument(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the INVALID_ARGUMENT gRPC status code. It indicates that an invalid argument was provided.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘invalid_argument’
- exception django_socio_grpc.exceptions.Unimplemented(detail=None, code=None)
Bases:
django_socio_grpc.exceptions.GRPCExceptionSubclass of GRPCException representing the UNIMPLEMENTED gRPC status code. It indicates that the requested operation is not yet implemented.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- status_code
None
- default_detail
‘_(…)’
- default_code
‘unimplemented’
- django_socio_grpc.exceptions.get_exception_status_code_and_details(exc: Exception) tuple[grpc.StatusCode, str]
Get the gRPC status code and details from the exception.
rest_framework.exceptions.APIExceptionHTTP status codes are mapped to gRPC status codes. Other exceptions are mapped togrpc.StatusCode.UNKNOWN. Their details are the exception class name. In debug mode, the details are the exception message.
- django_socio_grpc.exceptions.HTTP_CODE_TO_GRPC_CODE
None
Map HTTP status codes to gRPC status codes. Allows the handling of DRF exceptions. DSG must return gRPC status codes to the client.
https://grpc.github.io/grpc/core/md_doc_statuscodes.html https://www.rfc-editor.org/rfc/rfc9110.html