-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom ReachedMaxOrganizationMembersError
exception instead of generic ValidationError
#593
Custom ReachedMaxOrganizationMembersError
exception instead of generic ValidationError
#593
Conversation
c5e4313
to
4e758bb
Compare
@@ -167,3 +167,7 @@ class ProjectAlreadyExistsError(QFieldCloudException): | |||
code = "project_already_exists" | |||
message = "This user already owns a project with the same name." | |||
status_code = status.HTTP_400_BAD_REQUEST | |||
|
|||
|
|||
class ReachedMaxOrgaMembers(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ReachedMaxOrgaMembers(Exception): | |
class ReachedMaxOrganizationMembersError(ValidationError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I keep everything explicit without a lot of shortening. More typing, but clear explicitness.
Using ValidationError
as parent, will make Django help us in some situations with automatically showing the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite my "accept commit" the thing I don't like is that it's not a validation error, and moreover should not to have to declare a status_code
. That's why I refrained from sublcassing ValidationError
. Can we find a middle ground? Perhaps more fine-grained than an Exception but not a subtype of ValidationError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with your objections and it is something we can look into in the future for sure. Please add a TODO
comment as a reminder before the exception definition.
I would propose we keep it as a ValidationError
for now, until we find a better solution, so we minimize the risk of breaking something in the code that relied on this ValidationError
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, second thought. Define it like the rest of exceptions in the file, but extend QFieldCloudException
.
YOLO if someone relies on ValidationError
subclass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the just added status code is correct though.
Co-authored-by: Ivan Ivanov <suricactus@users.noreply.github.com>
ReachedMaxOrganizationMembersError
exception instead of generic ValidationError
You also need to fix the tests, e.g. |
No description provided.