smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.11k stars 1.17k forks source link

Can we have error constants? #871

Closed mikekonan closed 2 months ago

mikekonan commented 2 months ago

Hello,

As a user of the framework, I would like to perform type-checking on errors similar to how it's done in Go 1.13.

if errors.Is(err, ErrRPCService) {
}

Could we have error constants for scenarios like this?

https://github.com/smallnest/rpcx/blob/master/server/service.go#L355 https://github.com/smallnest/rpcx/blob/master/server/service.go#L381 Thanks!

smallnest commented 2 months ago

defined a error type:

type RpcServiceInternalError struct {
    Err    string
    Method string
    Argv   interface{}
    stack  string
}