github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/errors/wrapper.go (about) 1 package errors 2 3 import ( 4 "fmt" 5 ) 6 7 /* 8 Creation Time: 2021 - May - 21 9 Created by: (ehsan) 10 Maintainers: 11 1. Ehsan N. Moosa (E2) 12 Auditor: Ehsan N. Moosa (E2) 13 Copyright Ronak Software Group 2020 14 */ 15 16 func WrapText(txt string) func(err error) error { 17 return func(err error) error { 18 if err == nil { 19 return nil 20 } 21 22 return fmt.Errorf("%s: %v", txt, err) 23 } 24 } 25 26 func Wrap(wrapper error) func(err error) error { 27 return func(err error) error { 28 return fmt.Errorf("%s: %v", wrapper.Error(), err) 29 } 30 }