Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
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:
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:
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: