Skip to content

Instantly share code, notes, and snippets.

@ncdc
Created November 29, 2018 20:10
Show Gist options
  • Save ncdc/9b648221eb0975938337ca7252133426 to your computer and use it in GitHub Desktop.
Save ncdc/9b648221eb0975938337ca7252133426 to your computer and use it in GitHub Desktop.
func (s *server) run() error {
// do things
widget, err := widgetClient.Foo("abc")
if err != nil {
// QUESTION: what should the top of the stack be (what line)?
optionallyLogStackAtDebugLogLevel(err)
// other error handling
}
}
func (c *WidgetGRPCClient) Foo(s string) (Widget, error) {
response, err := c.grpcClient.Foo(context.Background(), &proto.FooRequest{S: s})
if err != nil {
return nil, convertGRPCError(err)
}
// ...
}
func (s *WidgetGRPCServer) Foo(ctx context.Context, req *proto.FooRequest) (*proto.FooResponse, error) {
widget, err := s.widgetImpl.Foo(req.S)
if err != nil {
return nil, toGRPCError(err)
}
// ...
}
func (w *widgetImpl) Foo(s string) (Widget, error) {
// do stuff
// oh no, an error!
return nil, newBadWidgetError()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment