some better error handling
This commit is contained in:
parent
be4c6cdeb8
commit
6cf9d75c81
13
replacer.py
13
replacer.py
|
@ -40,7 +40,20 @@ dprint = ContextVar('dprint')
|
|||
http = ContextVar('http')
|
||||
|
||||
async def handler(request):
|
||||
try:
|
||||
await _handler(request)
|
||||
except aiohttp.ClientConnectorError:
|
||||
raise web.HTTPServiceUnavailable(
|
||||
text=f'{request.host} is temporarily unavailable. Try again later.',
|
||||
)
|
||||
|
||||
async def _handler(request):
|
||||
try:
|
||||
hconfig = config['hosts'][request.host]
|
||||
except KeyError:
|
||||
# this should only happen if our reverse proxy is set to proxy everything to us
|
||||
raise web.HTTPNotFound()
|
||||
|
||||
dprint.set(dprint_factory())
|
||||
async with http().request(
|
||||
request.method,
|
||||
|
|
Loading…
Reference in New Issue