Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Exception Handling
    primarykey
    data
    text
    <p>This is a general question regarding exception handing for exceptions thrown in onther people's code.</p> <p>I am using the following Codeigniter PHP library: <a href="https://github.com/sepehr/ci-mongodb-base-model" rel="nofollow">https://github.com/sepehr/ci-mongodb-base-model</a></p> <p>which relies upon this library for MongoDB: <a href="https://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2" rel="nofollow">https://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2</a></p> <p>If I call a function in the first library, and it then calls one from the second. Sometimes the second library throws exceptions which I want to be able to deal with in my own code, but there is a try-catch statement around the exception throwing call, which means that it is dealt with before I get a chance to (I just prints the exception to the screen).</p> <p>My question is:</p> <p>Without modifying all of the functions in the first and second libraries (i.e. removing all of the try catches), how can I deal with the exception that is thrown?</p> <p><strong>EDIT</strong></p> <p>This is how the functions in the second library are arranged:</p> <pre><code>class SomeClass { function do_something() { ... try { ... } catch { $this-&gt;_show_error('Update of data into MongoDB failed: ' . $exception-&gt;getMessage(), 500); } } function _show_error($error_message = '', $response_code = 500) { //Inbuilt Codeigniter helper function which can be disabled from printing the error to the screen show_error($error_message, $response_code); } } </code></pre> <p>Although I can disable the error from being printed (which is of course just for debugging), I still have no way of knowing that it occurred and handling it. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload