@@ -495,6 +495,28 @@ proposal](https://go.googlesource.com/proposal/+/master/design/29934-error-value
495495 printing out error details, and knows how to present a chain of
496496 causes in a semi-structured format upon formatting with ` %+v` .
497497
498+ ### Ensuring ` errors.Is` works when packages are renamed
499+
500+ If a Go package containing a custom error type is renamed, or the
501+ error type itself is renamed, and errors of this type are transported
502+ over the network, then another system with a different code layout
503+ (e.g . running a different version of the software) may not be able to
504+ recognize the error any more via ` errors.Is` .
505+
506+ To ensure that network portability continues to work across multiple
507+ software versions, in the case error types get renamed or Go packages
508+ get moved / renamed / etc, the server code must call
509+ ` errors.RegisterTypeMigration()` from e.g . an ` init()` function.
510+
511+ Example use:
512+
513+ ` ` ` go
514+ previousPath := "github.com/old/path/to/error/package"
515+ previousTypeName := "oldpackage.oldErrorName"
516+ newErrorInstance := &newTypeName{...}
517+ errors.RegisterTypeMigration(previousPath, previousTypeName, newErrorInstance)
518+ ` ` `
519+
498520## Error composition (summary)
499521
500522| Constructor | Composes |
@@ -552,6 +574,9 @@ type LeafDecoder = func(ctx context.Context, msg string, safeDetails []string, p
552574type WrapperEncoder = func(ctx context.Context, err error) (msgPrefix string, safeDetails []string, payload proto.Message)
553575type WrapperDecoder = func(ctx context.Context, cause error, msgPrefix string, safeDetails []string, payload proto.Message) error
554576
577+ // Registering package renames for custom error types.
578+ func RegisterTypeMigration(previousPkgPath, previousTypeName string, newType error)
579+
555580// Sentry reports.
556581func BuildSentryReport(err error) (*sentry.Event, map[string]interface{})
557582func ReportError(err error) (string)
0 commit comments