From ba28b4d7b7678201469352550ee768307b4fbd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Thu, 28 Oct 2021 16:24:34 +0200 Subject: [PATCH] Send errors to Discord --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 17a8dff..a018965 100644 --- a/main.py +++ b/main.py @@ -6,9 +6,11 @@ import sys from datetime import datetime from pathlib import Path +from dhooks import Webhook from fastapi import FastAPI, File, UploadFile from fastapi.responses import HTMLResponse +hook = Webhook(os.environ["WEBHOOK"]) app = FastAPI() try: @@ -42,7 +44,8 @@ async def upload_file(file: UploadFile = File(...)): Path(output_folder).mkdir(parents=True, exist_ok=True) except Exception as e: - print(e) # TODO: Send to Discord + print(f"Failed to get content type/create folder: {e}") + hook.send(f"Failed to get content type/create folder: {e}") print(file.filename) file_location = f"{output_folder}/{file.filename}"