Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php try { processPayment($order); } catch (InvalidCardException $e) { // Card-specific handling return ["error" => "card_invalid", "msg" => $e->getMessage()]; } catch (InsufficientFundsException $e) { return ["error" => "insufficient_funds", "msg" => $e->getMessage()]; } catch (NetworkException | TimeoutException $e) { // Handle both network and timeout the same way return ["error" => "network_error", "retry" => true]; } catch (Exception $e) { // Catch-all for unexpected errors error_log($e->getMessage()); return ["error" => "unexpected"]; }
Result
Open