diff --git a/svc/routes/customer_balance_pdf.go b/svc/routes/customer_balance_pdf.go index 48a1d12..6a1e26e 100644 --- a/svc/routes/customer_balance_pdf.go +++ b/svc/routes/customer_balance_pdf.go @@ -7,7 +7,9 @@ import ( "bytes" "database/sql" "fmt" + "log" "net/http" + "runtime/debug" "sort" "strconv" "strings" @@ -36,6 +38,13 @@ type balanceSummaryPDF struct { func ExportCustomerBalancePDFHandler(_ *sql.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + defer func() { + if rec := recover(); rec != nil { + log.Printf("PANIC ExportCustomerBalancePDFHandler: %v\n%s", rec, string(debug.Stack())) + http.Error(w, "internal server error", http.StatusInternalServerError) + } + }() + claims, ok := auth.GetClaimsFromContext(r.Context()) if !ok || claims == nil { http.Error(w, "unauthorized", http.StatusUnauthorized)