Skip to content

Commit a36e472

Browse files
lweb20chriskacerguis
authored andcommitted
Add config to handle or not exceptions (chriskacerguis#739)
1 parent 7e1c22c commit a36e472

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

application/config/rest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@
229229
*/
230230
$config['rest_ip_whitelist_enabled'] = FALSE;
231231

232+
/*
233+
|--------------------------------------------------------------------------
234+
| REST Handle Exceptions
235+
|--------------------------------------------------------------------------
236+
|
237+
| Handle exceptions caused by the controller
238+
|
239+
*/
240+
$config['rest_handle_exceptions'] = TRUE;
241+
232242
/*
233243
|--------------------------------------------------------------------------
234244
| REST IP White-list

application/libraries/REST_Controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public function __destruct()
595595
* Checks to see if we have everything we need to run this library.
596596
*
597597
* @access protected
598-
* @@throws Exception
598+
* @throws Exception
599599
*/
600600
protected function preflight_checks()
601601
{
@@ -739,6 +739,10 @@ public function _remap($object_called, $arguments = [])
739739
}
740740
catch (Exception $ex)
741741
{
742+
if ($this->config->item('rest_handle_exceptions') === FALSE) {
743+
throw $ex;
744+
}
745+
742746
// If the method doesn't exist, then the error will be caught and an error response shown
743747
$_error = &load_class('Exceptions', 'core');
744748
$_error->show_exception($ex);

0 commit comments

Comments
 (0)