Jump to content

[SOLVED] catching exceptions


caedo

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.