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

Errors are not reported and displayed on production #2540

Closed
AidasK opened this issue Mar 13, 2024 · 0 comments
Closed

Errors are not reported and displayed on production #2540

AidasK opened this issue Mar 13, 2024 · 0 comments

Comments

@AidasK
Copy link
Contributor

AidasK commented Mar 13, 2024

Description

Errors are not reported and displayed on production

Steps to reproduce

Create a twill block which uses some undefined variable. This block will fail and error won't be displayed and reported in production.
https://github.com/area17/twill/blob/3.x/src/Services/Blocks/Block.php#L688

Expected result

I would expect to have this error logged and reported to my error tracker and this page should not load for my users so that I could fix it asap.

Actual result

App just crashes silently

Versions

Twill version: 3.2
Laravel version: 11.0
PHP version: 8.3

Solution A

https://github.com/area17/twill/blob/3.x/src/Services/Blocks/Block.php#L688
Change to:

        try {
            return view($view, $data)->render();
        } catch (Exception $e) {
            if (config('twill.strict')) {// can be named throw or something
                throw $e;
            }
            if (config('twill.debug')) {
                $error = $e->getMessage() . ' in ' . $e->getFile();

                return View::make('twill::errors.block', ['view' => $view, 'error' => $error])->render();
            }
            report($e);// add this
        }
       
        return '';

Solution B, my favorite:

This entire logic does not seem to be useful and can be added specifically by any application if needed. So I would suggest to just drop try catch block entirely. Just look how beautiful it is:

     return view($view, $data)->render();
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