Ticket #5310 defect new
WrapperException makes debugging Agent hard
| Reported by: | glyph | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | web | Keywords: | |
| Cc: | jknight | Branch: | |
| Author: | Launchpad Bug: |
Description
If request generation fails with Agent it is difficult to debug because _WrapperException swallows tracebacks automatically and provides no facility to extract them manually.
For example, this (buggy) program:
from twisted.internet import reactor from twisted.web.client import Agent agent = Agent(reactor) class Whatever(object): """ I should probably implement some interfaces or something. """ def done(it): reactor.stop() return it (agent.request("POST", "http://example.com/", bodyProducer=Whatever()) .addBoth(done)) reactor.run()
produces the following inscrutable output:
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
Failure: twisted.web._newclient.RequestGenerationFailed: [
<twisted.python.failure.Failure <type 'exceptions.AttributeError'>>]
RequestGenerationFailed apparently has no public alias; neither does _WrapperException, which means that there's no way to catch this exception and do better error reporting without resorting to importing private names.
Also, _WrapperException's documentation is wrong: while its subclasses get things right, it says that reasons is a list of exceptions, when it is in fact a list of Failures.
Change History
Note: See
TracTickets for help on using
tickets.
