errors.py 1.12 KB
Newer Older
1 2 3
class LDPLoginError(Exception):
    _errors = {
        'invalid_request': "The request provider parameter must contains an url or an email",
4 5
        'invalid_state': "Invalid state",
        'wrong_issuer': "Cannot find OP client from this issuer",
6
        'cannot_get_provider_info': "Cannot get provider informations",
7
        'cannot_get_webid': "Cannot get the webid",
8
        'id_token_expired': "The ID Token is expired",
9
        'cannot_confirm_webid': "Cannot confirm the webid. Is your authentication server host same as your webid host ?",
10 11 12
        'cannot_register': "Unable to register, is the provider accepting registration ? If not contact <todo : give an email> to make a manual registration"
    }

13 14 15 16 17 18 19
    def __init__(self, error=None, dict=None):
        if dict is None:
            self.error = error
            self.description = self._errors.get(error)
        else:
            self.error = dict['error']
            self.description = dict['error_description']
20 21 22 23 24 25 26 27

    def create_dict(self):
        dic = {
            'error': self.error,
            'error_description': self.description,
        }

        return dic