3

Is there a way in PHP to make sure that I get Exceptions for everything rather than errors?

Using two different methods of errorhandling leaves me uncomfortable and it feels messy. I'd prefer the Exception style method as its more OO and thus fits better with my other programming experience.

2
  • please provide an example. did you mean php errors? The question should be: is it useful to catch errors... Commented Oct 8, 2009 at 8:08
  • No, I wanted to know if it was possibly to generalise to one way of error handling. Raising an exception with the default error handler seems like the closest answer but still not ideal... but thats PHP for you ;) Commented Oct 8, 2009 at 10:13

1 Answer 1

3

you can set the default error handler to only throw an exception. you can then handle all exceptions in your default exception handler.

See set_error_handler()

Sign up to request clarification or add additional context in comments.

1 Comment

Just to add: There is a built-in exception class for this use-case, the ErrorException: us2.php.net/manual/en/class.errorexception.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.