mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-07 14:00:08 +02:00
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.
This commit is contained in:
@ -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))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
Reference in New Issue
Block a user