Opened 9 years ago

Closed 9 years ago

#5345 enhancement closed duplicate (duplicate)

it's very difficult to debug response generation with twisted.web.client.Agent

Reported by: Glyph Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


If request generation fails with Agent it is very difficult to debug.

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):
    return it
(agent.request("POST", "", bodyProducer=Whatever())

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 (2)

comment:1 Changed 9 years ago by Glyph

This is related to #4659, and possibly a duplicate, but a bit more detailed.

comment:2 Changed 9 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Duplicate of #5310

Note: See TracTickets for help on using tickets.