caedo Posted July 8, 2008 Share Posted July 8, 2008 Good day, I'm having problems using exceptions in the following code: private function readFile($file){ //this wont work and will throw the exception. if($handle = fopen($file.'asdasdasdasdas', "rb")){ }else{ throw new Exception('Unable to load'); } } try{ $this->readFileForModules($file); }catch (Exception $ex){ echo $ex->getMessage(); } It throws the exception but still, it throws the error too: Warning: fopen(C:\templates\basic.tplasdasdasdasdas) [function.fopen]: failed to open stream Unable to load I want that only the exception message is shown, not the error. can you help me? thanks in advance caedo Link to comment https://forums.phpfreaks.com/topic/113773-solved-catching-exceptions/ Share on other sites More sharing options...
DarkWater Posted July 8, 2008 Share Posted July 8, 2008 if($handle = @fopen($file.'asdasdasdasdas', "rb")){ Link to comment https://forums.phpfreaks.com/topic/113773-solved-catching-exceptions/#findComment-584649 Share on other sites More sharing options...
caedo Posted July 8, 2008 Author Share Posted July 8, 2008 thanks dark water, that solved the problem. Link to comment https://forums.phpfreaks.com/topic/113773-solved-catching-exceptions/#findComment-584653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.