Skip to content

Error when a handler returns something other than a Response #87

@samuelcolvin

Description

@samuelcolvin

currently

# @template('index.jinja')
async def index(request):
    return {
        'foo': 'bar'
    }

will give cause an error in aiohttp-debugtoolbar:

Traceback (most recent call last):
  File "/home/samuel/code/purge_cloudflare/env/lib/python3.5/site-packages/aiohttp/web_server.py", line 61, in handle_request
    resp = yield from self._handler(request)
  File "/home/samuel/code/purge_cloudflare/env/lib/python3.5/site-packages/aiohttp/web.py", line 249, in _handle
    resp = yield from handler(request)
  File "/home/samuel/code/purge_cloudflare/env/lib/python3.5/site-packages/aiohttp_debugtoolbar/middlewares.py", line 122, in toolbar_middleware
    toolbar.status = response.status
AttributeError: 'dict' object has no attribute 'status'

instead I guess debug toolbar should show the

AssertionError: Handler <function index at 0x7f1b927b6510> should return response instance, got <class 'dict'> [middlewares []]

as it does for standard exceptions occurring in a handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions