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

Clean up the controllers and treating exceptions #28

Open
TiagoSilvaPereira opened this issue Mar 14, 2018 · 2 comments
Open

Clean up the controllers and treating exceptions #28

TiagoSilvaPereira opened this issue Mar 14, 2018 · 2 comments
Labels
refactor code improvement & refactor
Milestone

Comments

@TiagoSilvaPereira
Copy link
Contributor

TiagoSilvaPereira commented Mar 14, 2018

Would be great clean up the controllers and move the extra logical code to repositories or models.

I realized that when a problem occurs with the DB::transaction, the controllers are not firing the exception, but only returning a error message. It is very difficult to track the errors occurred when saving or updating data.

Ex:

DB::beginTransaction();

try {
            ...
} catch (\Exception $e) {

            DB::rollback();

            // I think here we can throw an exception, with the message below. Then, on the
            // exceptions handler, we check if the system env is dev or production, to show the error
            // or only flash the message. 

            flash()->error('Error while creating the member');

            return redirect(action('MembersController@index'));

}
@ludo237
Copy link

ludo237 commented Mar 14, 2018

I think it's too early to tackle down exception even because on Laravel 5.5 and 5.6 you can handler everything using the renderable interface

@ajitbohra
Copy link
Member

@TiagoSilvaPereira, not just controllers we will need refactoring at lot more places, currently working on the items list for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor code improvement & refactor
Projects
None yet
Development

No branches or pull requests

3 participants