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 error reporting by appending previous exception messages #26

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

clue
Copy link
Member

@clue clue commented Oct 11, 2021

This changeset improves error reporting by appending previous exception messages. This improves DX by making it easier to see the underlying error causes without having to check the previous exception via $e->getPrevious().

Refs reactphp/socket#271

@clue clue added this to the v1.3.0 milestone Oct 11, 2021
@clue clue requested a review from WyriHaximus October 11, 2021 15:49
@@ -78,7 +82,7 @@ function buffer(ReadableStreamInterface $stream, $maxLength = null)
$reject(new \RuntimeException('Cancelled buffering'));
});

return $promise->then(null, function ($error) use (&$buffer, $bufferer, $stream) {
return $promise->then(null, function (\Exception $error) use (&$buffer, $bufferer, $stream) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't these be Throwable?

Copy link
Member

Choose a reason for hiding this comment

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

Not yet

Copy link
Contributor

Choose a reason for hiding this comment

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

Why? In case of a TypeError for example, it wont remove the listener here.

Copy link
Member Author

Choose a reason for hiding this comment

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

The promise is created a few lines above and only ever rejected with a RuntimeException, hence there's no need to check for Throwable here. Using a Throwable probably wouldn't hurt either in the long run once this targets only newer PHP versions, but at the moment nothing is gained by using Throwable.

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

Successfully merging this pull request may close these issues.

None yet

3 participants