Difference between error calls?

Moderator
Lähettäjä United States
Jäsen alkaen lokak. 2019

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?

Moderator
Lähettäjä United States
Jäsen alkaen lokak. 2019

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

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.

Moderator
Lähettäjä United States
Jäsen alkaen lokak. 2019

My mistake. I didn't place the exception inside the try{} block so, of course, it wasn't caught. 😣

Sinä
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.