You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
blasthttp.mock raises RuntimeError where the real client raises TransportError #140
On the 1.0 branch (#128, as of 3e1629e), the real client raises TransportError for every failed request. The mock raises a plain RuntimeError instead:
an unmocked URL: "No mock response registered for {method} {url}" (src/mock.rs:442)
too many redirects during mock dispatch (src/mock.rs:804)
TransportError subclasses RuntimeError, so code written as except RuntimeError behaves the same against both. Code written against the new API, except TransportError and branching on e.kind, does not: under the mock, an unmocked URL escapes the handler and crashes the caller, where against the real client it would have been caught.
That forces consumers to keep catching RuntimeError and to guard every e.kind access with getattr, which defeats the point of the new exception. In BBOT's test suite, modules routinely hit URLs that a test doesn't mock, so this blocks BBOT from switching its handlers to TransportError.
Suggested fix: raise TransportError from the mock with the attributes filled in, for example kind="connection" for an unmocked URL and kind="too_many_redirects" for the redirect limit, with conclusion="unreachable". Ideally the mock could also be told to fail a URL with a chosen kind (timeout, tls, etc.), so consumers can test their handling of each one.
Activity
Carry TransportError on batch results, and raise it from the mock