PHP SDK - How to retrieve error code?

I use this function in PHP

try {
            $result = Backendless::$UserService->restorePassword($email);

        } catch (Exception  $e) {
            echo "Sorry, there was an error: ".$e->getMessage();

        }

If there is a valid email address in the database,no issues, $result = null.
But if there isn’t a valid entry in the database, I got an internal server error 500!

What am I doing wrong here? How do i retrieve the error code in PHP?

I can’t even catch the error in the catch block

Hi Peter,
What exception do you receive? Does it have id? Please post it here
Artur

I can’t seem to catch the exception; only the browser console reported a ‘500 (Internal Server Error)’

Did you try to debug?

Ok, it didnt generate an exception but spilled out a load of text.
managed to parse the text for errors.