Add more details to error message

This commit is contained in:
Daniel Egger 2023-07-21 09:22:54 +02:00
parent 5d0f7b88b5
commit dfc0a01e9f
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import traceback
from typing import Callable
from django.contrib import messages
@ -52,7 +53,12 @@ def handle_import(request, success_msg: str, importer: Callable[[str], None]):
try:
importer(excel_file)
except Exception as e:
return render(request, "admin/importer/error.html", {"error": str(e)})
return render(
# it is a "power" feature, so we will output the traceback on error
request,
"admin/importer/error.html",
{"error": traceback.format_exc()},
)
messages.info(request, success_msg)
return redirect("admin:index")