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?

1 Answer 1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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