serializes error messages into json format
This commit is contained in:
parent
b4377b2f54
commit
3cce89cbac
1 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import json
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
@ -32,8 +34,11 @@ def make_error(error, exc=None) -> dict:
|
||||||
async def report_error(app, exc, body: dict):
|
async def report_error(app, exc, body: dict):
|
||||||
try:
|
try:
|
||||||
if 'slack_webhook' in app['config']:
|
if 'slack_webhook' in app['config']:
|
||||||
|
body_dump = json.dumps(body, indent=4)
|
||||||
|
exec_name = type(exc).__name__
|
||||||
|
exec_body = str(exc)
|
||||||
message = {
|
message = {
|
||||||
"text": f"Got `{type(exc).__name__}`: `\n{str(exc)}`\n```{body}```"
|
"text": f"Got `{exec_name}`: `\n{exec_body}`\n```{body_dump}```"
|
||||||
}
|
}
|
||||||
async with aiohttp.ClientSession() as sesh:
|
async with aiohttp.ClientSession() as sesh:
|
||||||
async with sesh.post(app['config']['slack_webhook'], json=message) as resp:
|
async with sesh.post(app['config']['slack_webhook'], json=message) as resp:
|
||||||
|
|
Loading…
Reference in a new issue