errors/grpc.go
func FromGRPC(in error) Error {
	out := &impl{
		message: grpc.ErrorDesc(in),
		typ:     GRPCCodeToType(grpc.Code(in)),
		code:    NoCode,
	}

	matches := grpcMessageFormat.FindStringSubmatch(in.Error())

	if len(matches) < 4 {
		return out
	}

	out.message = matches[1]
	out.code = parseCode(matches[2])
	_ = json.Unmarshal([]byte(matches[3]), &out.attributes)

	got := Get(Code(out.code))
	if got == nil {
		return out
	}

	return got.New(out.attributes)
}
func FromGRPC(in error) Error {
	out := &impl{
		message: grpc.ErrorDesc(in),
		typ:     GRPCCodeToType(grpc.Code(in)),
		code:    NoCode,
	}

	matches := grpcMessageFormat.FindStringSubmatch(in.Error())

	if len(matches) < 4 {
		return out
	}

	out.message = matches[1]
	out.code = parseCode(matches[2])
	_ = json.Unmarshal([]byte(matches[3]), &out.attributes)

	got := Get(Code(out.code))
	if got == nil {
		return out
	}

	return got.New(out.attributes)
}
// FromGRPC parses a gRPC error and returns an Error