I’m developing a WordPress Theme a little more complex than usual. One of these complexities involves PHP Exceptions.
As usual, I have a menu created with add_menu_page() and its child with add_submenu_page().
The last argument of add_submenu_page() is a callback function and I’m dispatching a class method here, using array notation:
array( $clasObj, $methodInvoked );
Fine! If something goes wrong here, one of my Exceptions is thrown and I have a specific action to take when (and if) this occur.
But I don’t know where to add the catch block.
I have a custom Exception Handler which describe in details the stack trace and I can see only two WordPress functions being called:
do_action() from admin.php passing as argument toplevel_page_slug_i_defined
call_user_func_array() from plugin.php passing as argument the array I described above, containing the class object and the method to be invoked.
I tried to add the catch block when the object is created, when add_submenu_page() is called and nothing! I even tried add it in functions.php file, where I start the whole process without success.
The only place I could effectively catch this Exception was inside the Controller, but doesn’t make sense to repeat all the routines in every Controller class and in every Action.
- The topic ‘Catch Exception thrown after add_submenu_page() be invoked’ is closed to new replies.