/ Published in: PHP

Some working example code snippet..
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function hideme($auth=''){ //try something first try{ //if not TRUE throw an exception with error message //following lines won't work if an exception occur //another method where an exception may occur $this->checkNum($auth); //the last line of try catch block and if you see this text. Error FREE :) echo 'You passed a number :: '.$auth; //catch specific kohana_user_exception because it inheritance from kohana_exception }catch(kohana_user_exception $e){ //call a method before die:: very useful for closing </html> tags or closing DB //not necessary in this sample code but if above exceptions fail to catch.. //at least parent exception should be called like this }catch(kohana_exception $e){ } } //to be called before die private function error_handler($e){ echo 'do something before die!<br />'; echo $e; } function checkNum($num){ if(!(int)$num > 0) throw new Kohana_User_Exception('Invalid Number','This value is not a number. Please provide a valid number.'); return TRUE; }
Comments
