Changeset 0339ba9 in trunk
- Timestamp:
- 2020-10-16T13:52:41Z (4 years ago)
- Branches:
- master
- Children:
- 0faa24d
- Parents:
- fa02e46
- git-author:
- Jean-Paul Calderone <exarkun@…> (2020-10-15 20:14:06)
- git-committer:
- Jean-Paul Calderone <exarkun@…> (2020-10-16 13:52:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/web/common.py ¶
rfa02e46 r0339ba9 21 21 ) 22 22 from twisted.web.util import ( 23 DeferredResource, 23 24 FailureElement, 24 25 redirectTo, … … 460 461 461 462 462 def exception_to_child( f):463 def exception_to_child(getChild): 463 464 """ 464 465 Decorate ``getChild`` method with exception handling behavior to render an 465 466 error page reflecting the exception. 466 467 """ 467 @wraps( f)468 @wraps(getChild) 468 469 def g(self, name, req): 469 try: 470 return f(self, name, req) 471 except Exception as e: 472 description, status = humanize_exception(e) 473 return resource.ErrorPage(status, "Error", description) 470 bound_getChild = getChild.__get__(self, type(self)) 471 result = maybeDeferred(bound_getChild, name, req) 472 result.addCallbacks( 473 _getChild_done, 474 _getChild_failed, 475 callbackArgs=(self,), 476 ) 477 return DeferredResource(result) 474 478 return g 479 480 481 def _getChild_done(child, parent): 482 if child is None: 483 return resource.NoResource() 484 return child 485 486 487 def _getChild_failed(reason): 488 text, code = humanize_failure(reason) 489 return resource.ErrorPage(code, "Error", text) 475 490 476 491
Note: See TracChangeset
for help on using the changeset viewer.