github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/error/util.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package error 4 5 import ( 6 "github.com/GeniusesGroup/libgo/protocol" 7 ) 8 9 func ToGoError(err protocol.Error) error { 10 if err == nil { 11 return nil 12 } 13 14 var exErr = err.(*Error) 15 if exErr != nil { 16 return exErr 17 } 18 19 return &errorString{msg: err.ToString()} 20 } 21 22 // errorString is a trivial implementation of error. 23 type errorString struct { 24 msg string 25 } 26 27 func (e *errorString) Error() string { return e.msg } 28 29 func ToError(err error) protocol.Error { 30 if err == nil { 31 return nil 32 } 33 34 var exErr = err.(*Error) 35 if exErr != nil { 36 return exErr 37 } 38 // TODO::: 39 return nil 40 }