diff --git a/matrix_alertbot/webhook.py b/matrix_alertbot/webhook.py index b093343..7443d9a 100644 --- a/matrix_alertbot/webhook.py +++ b/matrix_alertbot/webhook.py @@ -70,7 +70,7 @@ async def create_alerts(request: web_request.Request) -> web.Response: config: Config = request.app["config"] if room_id not in config.allowed_rooms: - logger.error("Cannot send alerts to room ID {room_id}.") + logger.error(f"Cannot send alerts to room ID {room_id}.") return web.Response( status=401, body=f"Cannot send alerts to room ID {room_id}." ) @@ -115,12 +115,20 @@ async def create_alerts(request: web_request.Request) -> web.Response: ) except (SendRetryError, LocalProtocolError, ClientError) as e: logger.error( - f"Unable to send alert {alert.fingerprint} to Matrix room: {e}" + f"Unable to send alert {alert.fingerprint} to Matrix room {room_id}: {e}" ) return web.Response( status=500, body=f"An error occured when sending alert with fingerprint '{alert.fingerprint}' to Matrix room.", ) + except Exception as e: + logger.error( + f"Unable to send alert {alert.fingerprint} to Matrix room {room_id}: {e}" + ) + return web.Response( + status=500, + body=f"An exception occured when sending alert with fingerprint '{alert.fingerprint}' to Matrix room.", + ) return web.Response(status=200)