Ticket #5310 defect new

Opened 21 months ago

Last modified 2 months ago

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

1

Changed 21 months ago by DefaultCC Plugin

  • cc jknight added

2

Changed 20 months ago by exarkun

For some reason this was filed again as #5345

3

Changed 2 months ago by therve

And was already filed as #4659, but I kept this one.

Note: See TracTickets for help on using tickets.