From 40ecb7b06b08f1e803d3ae4d59eeaf9bebcd6491 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 27 Oct 2021 22:05:07 +0800 Subject: Define UsernameTakenError --- jimbrella/exceptions.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'jimbrella') diff --git a/jimbrella/exceptions.py b/jimbrella/exceptions.py index ad92b50..c0cc055 100644 --- a/jimbrella/exceptions.py +++ b/jimbrella/exceptions.py @@ -25,3 +25,12 @@ class UmbrellaValueError(Exception): self.field = field self.message = f"Invalid field: {field}." super().__init__(self.message) + + +class UsernameTakenError(Exception): + """For when a username to be registered with is already taken.""" + + def __init__(self, username: str): + self.username = username + self.message = f"Username {username} is already taken." + super().__init__(self.message) -- cgit v1.2.3