You'll have to write specific handlers that send back specific messages indicating the exception that was thrown.
Aug 3, 2016
2
Level 6
"catching" specific PHP exception with ajax...
Let's say I make an AJAX request to my PHP application, and a FooException is thrown, and a 500 error is returned. The response would look something like:
{
message: "Uh oh! Foo went wrong!",
code: "42S02",
status_code: "500"
}
I want to execute a specific action if the back-end throws a FooException, but not any other type of exception. Is it possible for the front-end to detect the type of exception that was thrown, and react to it accordingly? I don't want to base the action off of the status code, because other exceptions might return the same code (in this case, 500).
Please or to participate in this conversation.