Browse Source

better exception message for user api

Guénaël Muller 6 years ago
parent
commit
60841695e3
1 changed files with 4 additions and 4 deletions
  1. 4 4
      tracim/lib/core/user.py

+ 4 - 4
tracim/lib/core/user.py View File

@@ -73,7 +73,7 @@ class UserApi(object):
73 73
         Get current_user
74 74
         """
75 75
         if not self._user:
76
-            raise UserDoesNotExist()
76
+            raise UserDoesNotExist('There is no current user')
77 77
         return self._user
78 78
 
79 79
     def get_all(self) -> typing.Iterable[User]:
@@ -102,9 +102,9 @@ class UserApi(object):
102 102
             if user.validate_password(password):
103 103
                 return user
104 104
             else:
105
-                raise WrongUserPassword()
106
-        except (WrongUserPassword, UserDoesNotExist):
107
-            raise AuthenticationFailed()
105
+                raise WrongUserPassword('User "{}" password is incorrect'.format(email))  # nopep8
106
+        except (WrongUserPassword, UserDoesNotExist) as exc:
107
+            raise AuthenticationFailed('User "{}" authentication failed'.format(email)) from exc  # nopep8
108 108
 
109 109
     # Actions
110 110