Avoid logging error messages for webhook request failures

This commit is contained in:
Marcus Moore 2023-10-10 15:06:08 -07:00
parent f685ba01b6
commit 47a77eabf2

View file

@ -18,6 +18,7 @@ use App\Notifications\CheckoutAccessoryNotification;
use App\Notifications\CheckoutAssetNotification;
use App\Notifications\CheckoutConsumableNotification;
use App\Notifications\CheckoutLicenseSeatNotification;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Support\Facades\Notification;
use Exception;
use Log;
@ -61,6 +62,16 @@ class CheckoutableListener
);
}
} catch (Exception $e) {
if ($e instanceof ClientException){
$statusCode = $e->getResponse()->getStatusCode();
// If status code is in 400 range, we don't want to log it as an error
// @todo: 300 and 500 as well?
if ($statusCode >= 400 && $statusCode < 500) {
Log::debug("Exception caught during checkout notification: ".$e->getMessage());
return;
}
}
Log::error("Exception caught during checkout notification: ".$e->getMessage());
}
}