mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01: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:
parent
66ca2a994b
commit
bd291286f7
1 changed files with 9 additions and 2 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue