5

I need to access an instance of JImage in a template and when calling

$image->getPath()

want to catch InvalidArgumentException in case the image file is not on disk.

I tried:

try{
    echo $image->getPath();
}catch (Exception $e){
    $test = 1;
}

But instead of catching the Exception the debugger always leads me to

/libraries/cms/error/page.php, function render(Exception $error)

What am I doing wrong?

3

get->Path() method actually does not throw an Exception, so you can not catch it. InvalidArgumentException is thrown in loadFile() method, so may be you should use it for your check.

  • Absolutely correct, thanks for pointing this out. – jdog Jul 23 '14 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.