Skip to content
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

Allow exceptions in actions #8000

Closed
hypeJunction opened this issue Feb 24, 2015 · 6 comments
Closed

Allow exceptions in actions #8000

hypeJunction opened this issue Feb 24, 2015 · 6 comments

Comments

@hypeJunction
Copy link
Contributor

Perhaps we could considering wrapping action() with try() and catch exceptions. Users would get generic messages based on exception type, admins would get full exception messages.

I realize that I spend too much time checking instances, canEdit(), canWriteToContainer() permissions and inventing smart error messages. Would be helpful to have an easy way out by throwing an exception from one of the classes.

@ewinslow
Copy link
Contributor

+1

@ewinslow ewinslow added this to the Revamp forms/actions milestone Feb 24, 2015
@mrclay
Copy link
Member

mrclay commented Feb 24, 2015

I agree that there's too much boilerplate around validation, and the idea seems somewhat easy to implement. Only hesitation is that it feels like an abuse of exceptions (goto).

@Srokap
Copy link
Contributor

Srokap commented Feb 24, 2015

Fine with me if we stick to specific type of exceptions to be caught and handled as generic messages. We should perhaps differentiate explicitly here between 400 errors and 500, when first ones are caused by bad input data and the latter are server side issues (DB unreachable etc.)

@hypeJunction
Copy link
Contributor Author

@mrclay Classes already throw exceptions that unless are caught in the action result in inconveniences for admins and users, e.g. calling ->save() with a container guid that the user has no write permissions to will result in an Exception (something about can't save base entity information). So, we keep repeating canEdit() and canWriteToContainer() calls in every action. These could easily be thrown as Exceptions from ->save() with a generic message that include entity info or type/subtype info.

@jdalsem
Copy link
Member

jdalsem commented Jan 19, 2018

@hypeJunction was this fixed somewhere along the line?

@hypeJunction
Copy link
Contributor Author

HttpException can be thrown and will result in error response out of action. I don't think we need anything else at the moment

@jdalsem jdalsem closed this as completed Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants