Skip to content

Commit

Permalink
Allow to disable exception throwing in the View destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Mar 1, 2025
1 parent ed98bb8 commit f36994b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ View Config Options
'layout_prefix' => null,
'include_prefix' => null,
'show_debug_comments' => true,
'throw_exceptions_in_destructor' => true,
],
],
]
Expand Down Expand Up @@ -1296,6 +1297,12 @@ show_debug_comments

Set to ``false`` to disable HTML comments when in debug mode.

throw_exceptions_in_destructor
""""""""""""""""""""""""""""""

Set ``false`` to not throw exceptions in the class destructor. The default is to
throw. Disabling this will help you debug exceptions thrown inside views.

Extending
#########

Expand Down
3 changes: 3 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,9 @@ protected static function setView(string $instance) : View
if (isset($config['show_debug_comments']) && $config['show_debug_comments'] === false) {
$service->disableDebugComments();
}
if (isset($config['throw_exceptions_in_destructor'])) {
$service->setThrowExceptionsInDestructor($config['throw_exceptions_in_destructor']);
}
return static::setService('view', $service, $instance);
}

Expand Down
1 change: 1 addition & 0 deletions tests/configs/view.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
'layout_prefix' => '',
'include_prefix' => '',
'show_debug_comments' => false,
'throw_exceptions_in_destructor' => false,
],
];

0 comments on commit f36994b

Please sign in to comment.