Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a custom Exception child to signal a return from prepare_data() and/or logger #3

Open
johnpbloch opened this issue Aug 4, 2014 · 0 comments

Comments

@johnpbloch
Copy link
Contributor

In the comments on the announcement post, Shaun Harding brought up the point that it's a bit counter intuitive to use an exception to tell the runner not to create an async task:

No offense... but this is really annoying...

try {
  $data = $this->prepare_data( $data );
} catch ( Exception $e ) {
  return;
}

If you're going to throw an exception, and go through the trouble of catching it, don't ignore it...

He followed up with another good point:

The intent may not be to catch errors, but should an exception get thrown due to an error, it will be caught and promptly ignored. If you're only looking to catch a very specific type of exception, then a specific type of exception should be defined. If you really must catch all exceptions, then logging the exception would be nice. There's no xdebug.scream to undo that suppression.

Let's use this issue thread to discuss the merits of the approaches he's suggesting:

  1. Use a custom Exception child class, or
  2. Add some sort of logging to the process that will log the exceptions that occur

We could even use both together to allow the logger to differentiate between different types of exceptions but still catch all types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant