1
0
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:
川桑 2022-07-10 00:39:44 +08:00 committed by GitHub
parent c9fbb27b5b
commit d88052b7dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,6 +106,9 @@ func Reason(err error) string {
// Clone deep clone error to a new error.
func Clone(err *Error) *Error {
if err == nil {
return nil
}
metadata := make(map[string]string, len(err.Metadata))
for k, v := range err.Metadata {
metadata[k] = v