From bd291286f73a4686f6d2e3880ee44152d2c03e36 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 27 Sep 2021 11:57:23 +0200 Subject: [PATCH] kvdb/postgres: convert all types of panic data to error Previously the assumption existed that panic data was already an error. If that wasn't the case for example because panic("string") was used, the transaction wasn't unlocked. --- kvdb/postgres/db.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kvdb/postgres/db.go b/kvdb/postgres/db.go index 0db46b6df..3276fb557 100644 --- a/kvdb/postgres/db.go +++ b/kvdb/postgres/db.go @@ -151,8 +151,15 @@ func (db *db) getPrefixedTableName(table string) string { func catchPanic(f func() error) (err error) { defer func() { if r := recover(); r != nil { - err = r.(error) - log.Criticalf("Caught unhandled error: %v", err) + log.Criticalf("Caught unhandled error: %v", r) + + switch data := r.(type) { + case error: + err = data + + default: + err = errors.New(fmt.Sprintf("%v", data)) + } } }()