Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Type error: expected Exception, got string with mock + log middleware #6

Open
Tobion opened this issue Jan 15, 2018 · 2 comments
Open

Comments

@Tobion
Copy link

Tobion commented Jan 15, 2018

The MockMiddleware creates a RejectedPromise with a string reason in https://github.com/csarrazi/guzzle-cache-middleware/blob/master/src/MockMiddleware.php#L47 if the cache is not found. The log middleware then fails because the MessageFormatter requires an exception in https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php#L70

It seems like a rejection reason does not necessarily need to be an exception because the reason is never typehinted in guzzle/promises. In this case the bug is more in Guzzle itself that the log middleware cannot deal with that.

Tobion added a commit to Tobion/guzzle-cache-middleware that referenced this issue Jan 15, 2018
@csarrazi
Copy link
Owner

Good catch @Tobion!

@csarrazi
Copy link
Owner

What we can do there is simply change the reason to be an instance of an Exception type, which could then be handled by the log handler. I'm not sure, but this may need some changes in the data collector, as I am not entirely certain about how Guzzle actually handles errors (as you mentioned, because of the missing type hint, it is a bit of a grey area).

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

No branches or pull requests

2 participants