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

datatables.error = null should respect app.debug & not show exception details to user #1582

Open
nie7321 opened this issue Jan 17, 2018 · 1 comment

Comments

@nie7321
Copy link

nie7321 commented Jan 17, 2018

Summary of problem or feature request

When the app.debug flag is set to false, SQL errors in the filtering code are causing a popup for the end-user with the exception (in this case, the SQL error).

Per the config/datatables.php file, I can control this behaviour pretty easily:

    /**
     * User friendly message to be displayed on user if error occurs.
     * Possible values:
     * null             - The exception message will be used on error response.
     * 'throw'          - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed.
     * 'custom message' - Any friendly message to be displayed to the user. You can also use translation key.
     */
    'error'          => env('DATATABLES_ERROR', null),

I would suggest changing the behaviour if the settings is left null: when app.debug = false, default to a custom message instead of exposing the exception to an end-user. This would be more consistent with how the rest of the framework behaves.

I can take a stab at a PR if you concur that this is a good idea.

System details

Laravel 5.5.28, PHP 7.1.8, and Laravel-Datatables 1.0.0

@yajra
Copy link
Owner

yajra commented Jan 18, 2018

Yes, I agree with you. It's actually on my notes but haven't got the chance to implement it. Can you please do submit a PR. TIA ❤️

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

No branches or pull requests

2 participants