mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-14 02:33:03 +02:00
fix(errors): panic when err of Clone is nil (#2176)
This commit is contained in:
parent
c9fbb27b5b
commit
d88052b7dd
@ -106,6 +106,9 @@ func Reason(err error) string {
|
|||||||
|
|
||||||
// Clone deep clone error to a new error.
|
// Clone deep clone error to a new error.
|
||||||
func Clone(err *Error) *Error {
|
func Clone(err *Error) *Error {
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
metadata := make(map[string]string, len(err.Metadata))
|
metadata := make(map[string]string, len(err.Metadata))
|
||||||
for k, v := range err.Metadata {
|
for k, v := range err.Metadata {
|
||||||
metadata[k] = v
|
metadata[k] = v
|
||||||
|
Loading…
Reference in New Issue
Block a user