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

Improve try catch middleware #23

Merged
merged 2 commits into from Oct 5, 2018
Merged

Improve try catch middleware #23

merged 2 commits into from Oct 5, 2018

Conversation

mabar
Copy link
Contributor

@mabar mabar commented Oct 2, 2018

Closes #20

@mabar
Copy link
Contributor Author

mabar commented Oct 2, 2018

@f3l1x I am thinking about little bit more complicated configuration.

We have two options in Apitte for catching exceptions - catchExceptions and debug.
Exceptions are displayed only if catchException is false and debug is true. It is useful because only in debug mode (set via %debug%) could be exception displayed and because in debug mode you sometimes want see, what will be displayed to user instead of exception.

Similar way is also used in nette/application https://github.com/nette/application/blob/master/src/Application/Application.php#L87-L91

/** @var LoggerInterface|null */
private $logger;

public function __construct(?LoggerInterface $logger = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but I would prefer set optionall dependencies via setter. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.

@@ -33,4 +43,11 @@ public function setCatchExceptions(bool $catch): void
$this->catch = $catch;
}

private function logError(Throwable $throwable): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole middleware is about error/exceptions, so we can rename it to just log() function. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@f3l1x f3l1x merged commit 6695166 into master Oct 5, 2018
@f3l1x f3l1x deleted the improve-try-catch-mw branch October 5, 2018 18:27
@f3l1x f3l1x added this to the v0.8 milestone Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants