Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 266e1b4d

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Moved global error handlers out of the CertificateController to a separate file.
Renamed generic exception handlers.

Zobrazit rozdíly:

src/controllers/certificates_controller.py
65 65
E_INVALID_EXTENSIONS = {"success": False, "data": "Error occurred while creating a certificate. "
66 66
                                                  "It may be caused by wrong format of extensions."}
67 67

  
68
E_UNHANDLED_CRYPTOGRAPHY_ERROR = {"success": False, "data": "An unknown error has happened in the cryptography library."}
69
E_UNHANDLED_DATABASE_ERROR = {"success": False, "data": "An unknown database error has happened."}
70
E_UNHANDLED_ERROR = {"success": False, "data": "An unknown error has happened."}
71

  
72 68

  
73 69
class CertController:
74 70
    USAGE_KEY_MAP = {'CA': CA_ID, 'SSL': SSL_ID, 'digitalSignature': SIGNATURE_ID, 'authentication': AUTHENTICATION_ID}
......
772 768
                                                                                          identity_name,
773 769
                                                                                          identity_password)
774 770
                    return Response(identity_byte_array, mimetype='application/x-pkcs12')
775

  
776
    @staticmethod
777
    def handle_cryptography_error(e):
778
        Logger.error(f"An unhandled CryptographyException has been raised: {str(e)}")
779
        return E_UNHANDLED_CRYPTOGRAPHY_ERROR, C_INTERNAL_SERVER_ERROR
780

  
781
    @staticmethod
782
    def handle_database_error(e):
783
        Logger.error(f"An unhandled DatabaseException has been raised: {str(e)}")
784
        return E_UNHANDLED_DATABASE_ERROR, C_INTERNAL_SERVER_ERROR
785

  
786
    @staticmethod
787
    def handle_generic_exception(e):
788
        Logger.error(f"An unknown Exception ({type(e)}) has been raised: {str(e)}")
789
        return E_UNHANDLED_ERROR, C_INTERNAL_SERVER_ERROR

Také k dispozici: Unified diff