How do I throw a custom try-catch exception on CakePHP?
问题 I want to throw a custom exception which is the data validation exception in a controller of my CakePHP application. How do I create my own custom exception handler in Cakephp so that I can throw the exception and catch the exception? My code example: function getUserDetails($userid){ try{ if(!$validUser){ throw new Exception('Invalid User'); } return $userDetailsData; //returned from db }catch(Exception $e){ echo 'Error:'.$e->getMessage(); return; } } is it possible to use here custom