Try Catch: Error Handling

Roll over image to zoom in
{
// If the condition is met, throw an exception with a custom message
throw new Exception(“Number is too large!”);
}
// This line will not be executed if an exception is thrown above
echo “This will not be executed.”;
} catch (Exception $e) {
// Catch the exception and handle it gracefully
// Display the exception message to inform the user of the error
echo “Caught exception: ” . $e->getMessage();
}
?>