// WrapError wraps a given error such that it will be prefixed with the plugin
// name. This method should be used by facade implementations to wrap errors
// that come out of plugin implementations.
WrapError wraps a given error such that it will be prefixed with the plugin
name. This method should be used by facade implementations to wrap errors
that come out of plugin implementations.
// WrapError wraps a given error such that it will be prefixed with the plugin // name . This method should be used by facade implementations to wrap errors // that come out of plugin implementations .
func (f Facade) WrapErr(err error) error {
	if err == nil {
		return err
	}
	if st, ok := status.FromError(err); ok {
		pb := st.Proto()
		if message, ok := prefixMessage(f, pb.Message); ok {
			pb.Message = message
			return status.FromProto(pb).Err()
		}
		return err
	}
	if message, ok := prefixMessage(f, err.Error()); ok {
		return &facadeError{wrapped: err, message: message}
	}
	return err
}
func ( f Facade ) WrapErr ( err error ) error { if err == nil { return err } if st , ok := status . FromError ( err ) ; ok { pb := st . Proto ( ) if message , ok := prefixMessage ( f , pb . Message ) ; ok { pb . Message = message return status . FromProto ( pb ) . Err ( ) } return err } if message , ok := prefixMessage ( f , err . Error ( ) ) ; ok { return & facadeError { wrapped : err , message : message } } return err }
WrapError wraps a given error such that it will be prefixed with the plugin
name.
WrapError wraps a given error such that it will be prefixed with the plugin name .
// Embellish the gRPC status with the prefix, if necessary. // Care must be taken to preserve any status details. Therefore, the // proto is embellished directly and a new status created from that // proto. // Embellish the normal error with the prefix, if necessary. This is a // defensive measure since plugins go over gRPC.