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

Show friendly errors instead of exceptions #28

Open
AndreaLopezLozano opened this issue May 4, 2016 · 1 comment
Open

Show friendly errors instead of exceptions #28

AndreaLopezLozano opened this issue May 4, 2016 · 1 comment

Comments

@AndreaLopezLozano
Copy link

AndreaLopezLozano commented May 4, 2016

Show a friendly error message when it's not possible to delete a content because it has other contents related.

@ablunier
Copy link
Contributor

ablunier commented Sep 13, 2016

After researching about this, we found out that the only way to do it is capturing the Illuminate\Database\QueryException and checking the SQLSTATE number and the error number obtaining them from the Exception instance errorInfo property ($e->errorInfo).

Which SQL errors should crud capture and show as user friendly messages?

  • Error: 1451 SQLSTATE: 23000 (ER_ROW_IS_REFERENCED_2)
    Message: Cannot delete or update a parent row: a foreign key constraint fails (%s)
  • Error: 1452 SQLSTATE: 23000 (ER_NO_REFERENCED_ROW_2)
    Message: Cannot add or update a child row: a foreign key constraint fails (%s)

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

No branches or pull requests

2 participants