s22_tech Moderator Lähettäjä United States Jäsen alkaen lokak. 2019 s22_tech 7 helmik. 2025 18:44 What's the practical difference between using either: if (condition) { throw new Exception(language::translate('error_email_address_missmatch', 'The email addresses do not match')); } or if (condition) { notices::add('errors', language::translate('error_email_address_missmatch', 'The email addresses do not match')); header('Location: '. document::ilink()); exit; } to catch errors?
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 8 helmik. 2025 09:24 Exceptions can be caught. And I use them primarily for not having to do your second example multiple times. https://www.php.net/manual/en/language.exceptions.php
s22_tech Moderator Lähettäjä United States Jäsen alkaen lokak. 2019 s22_tech 8 helmik. 2025 19:13 Sometimes when I throw an Exception, it doesn't produce the text in a red banner. Instead it prints the raw error code on a blank page and I can't figure out why. Any ideas as to what to look for?
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 9 helmik. 2025 08:07 So, you use catch to make your own handler of the exception. If an exception is not caught, it ends up in PHP's error handler.
s22_tech Moderator Lähettäjä United States Jäsen alkaen lokak. 2019 s22_tech 8 maalisk. 2025 06:11 My mistake. I didn't place the exception inside the try{} block so, of course, it wasn't caught. 😣