Opened 3 years ago

Closed 3 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:
Author: Launchpad Bug:

Description

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

comment:1 Changed 3 years ago by glyph

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

comment:2 Changed 3 years ago by exarkun

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #5310

Note: See TracTickets for help on using tickets.