Skip to content

Commit

Permalink
Fix handling exceptions in circuits.web
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed Jan 31, 2017
1 parent b0b2eda commit af41949
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
32 changes: 0 additions & 32 deletions circuits/web/http.py
Expand Up @@ -421,38 +421,6 @@ def _on_request_complete(self, e, value):
res.body = value
self.fire(response(res))

@handler("exception")
def _on_exception(self, *args, **kwargs):
if not len(args) == 3:
return

etype, evalue, etraceback = args
fevent = kwargs["fevent"]

if isinstance(fevent, response):
res = fevent.args[0]
req = res.request
elif isinstance(fevent.value.parent.event, request):
req, res = fevent.value.parent.event.args[:2]
elif len(fevent.args[2:]) == 4:
req, res = fevent.args[2:]
elif len(fevent.args) == 2 and isinstance(fevent.args[0], socket):
req = wrappers.Request(fevent.args[0], server=self._server)
res = wrappers.Response(req, self._encoding, 500)
else:
return

if isinstance(evalue, HTTPException):
code = evalue.code
else:
code = None

self.fire(
httperror(
req, res, code=code, error=(etype, evalue, etraceback)
)
)

@handler("request_failure")
def _on_request_failure(self, erequest, error):
req, res = erequest.args
Expand Down
6 changes: 1 addition & 5 deletions tests/web/conftest.py
Expand Up @@ -3,7 +3,7 @@

import pytest

from circuits import Component, Debugger, handler
from circuits import Component, handler
from circuits.net.sockets import close
from circuits.web import Server, Static
from circuits.web.client import Client, request
Expand Down Expand Up @@ -55,10 +55,6 @@ def webapp(request, manager, watcher):
Root().register(webapp)
assert watcher.wait("registered")

if request.config.option.verbose:
Debugger().register(webapp)
assert watcher.wait("registered")

def finalizer():
webapp.fire(close())
assert watcher.wait("closed")
Expand Down

1 comment on commit af41949

@spaceone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prologic Can you describe this commit?

Please sign in to comment.