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

Catch Exception instead of Throwable #147

Merged
merged 6 commits into from Nov 8, 2020
Merged

Conversation

enumag
Copy link
Member

@enumag enumag commented Oct 23, 2020

When trying this lib together with amphp v3 I ran into a problem where a type error of passing a wrong argument somewhere was completely hidden and the test failed with simple "Connection closed" exception with no further indication of what went wrong.

After a while I found out that the type error was caught here and completely hidden by this library's error handling. In my opinion it's better to not catch ErrorException - those tend to be real bugs that you want to see right away.

Personally I'd be much more careful with catching Exception as well but that would require more knowledge.

@enumag
Copy link
Member Author

enumag commented Oct 23, 2020

Looks like even this broke the test so I'll have to spend a bit more time on it...

Still though this is not the first time where I saw this lib failing with simple connection closed, hiding the real issue completely. So I do believe something should be changed.

@prolic
Copy link
Member

prolic commented Oct 23, 2020

Good catch, thanks 👍

@prolic prolic added the bug Something isn't working label Oct 23, 2020
@enumag
Copy link
Member Author

enumag commented Oct 23, 2020

Well guess what... those errors that popped up now are genuine PHP errors that were always there just completely hidden.

The first one (and I'm really unsure how to fix it) is here. ($this->getConnection)() may return null - and often does.

@enumag
Copy link
Member Author

enumag commented Nov 1, 2020

@prolic Would you mind taking a look at this? From the code I really have no idea what your intention was.

@prolic
Copy link
Member

prolic commented Nov 2, 2020

Yes, will do.

@coveralls
Copy link

coveralls commented Nov 2, 2020

Pull Request Test Coverage Report for Build 795

  • 9 of 16 (56.25%) changed or added relevant lines in 8 files are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.09%) to 71.58%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ClientOperations/AbstractOperation.php 0 1 0.0%
src/ClientOperations/AbstractSubscriptionOperation.php 4 5 80.0%
src/Internal/EventStoreCatchUpSubscription.php 1 2 50.0%
src/Internal/ClusterDnsEndPointDiscoverer.php 0 2 0.0%
src/Transport/Tcp/TcpPackageConnection.php 1 3 33.33%
Files with Coverage Reduction New Missed Lines %
src/Internal/SubscriptionItem.php 3 77.78%
src/Internal/SubscriptionsManager.php 3 45.54%
Totals Coverage Status
Change from base Build 785: -0.09%
Covered Lines: 3380
Relevant Lines: 4722

💛 - Coveralls

@enumag
Copy link
Member Author

enumag commented Nov 2, 2020

Don't merge yet, I wanna check this again this weekend or so. (Quite busy now.)

@prolic
Copy link
Member

prolic commented Nov 2, 2020 via email

@enumag enumag merged commit 4bb9a65 into master Nov 8, 2020
@enumag enumag deleted the feature/exception-catching branch November 8, 2020 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants