I use https://github.com/jamesiarmes/php-ews library to access my exchange account.
If I used correct credentials to create a ExchangeWebServices object, I get accurate response.
$ews = new ExchangeWebServices("outlook.office365.com", "tes@abc.com", "test123");
$request = new EWSType_FindItemType();
$response = $ews->FindItem($request);
But If the credentials are wrong it breaks the site by throwing an exception as
EWS_Exception: SOAP client returned status of 401 in ExchangeWebServices->processResponse()
Is there any way to get the response as "failed" or some boolean value instead of the error message?