bblfsh / sdk

Babelfish driver SDK
GNU General Public License v3.0
23 stars 27 forks source link

Propagate more error types through gRPC #432

Closed dennwc closed 4 years ago

dennwc commented 4 years ago

Currently, our gRPC protocol only uses gRPC error codes for propagation. This significantly limits the number of possible errors that we can distinguish on the client side. This may be a problem for the client that want to skip some error cases like "unknown language" and "invalid file encoding".

This PR defines a new ErrorDetails protobuf message that will now be attached to all gRPC errors. It will provide all the information the client needs to reconstruct the error passed through the RPC channel.

In case the information is not available, implementation will fallback to the old behavior and will use error codes to distinguish errors.

The change also moves some of the error types from bblfshd to SDK. Once the new SDK version is released, we can remove those error types from bblfshd packages.

It also adds tests for gRPC error propagation.

Signed-off-by: Denys Smirnov denys@sourced.tech


This change is Reviewable

ncordon commented 4 years ago

Can you open an issue in the bbfshd to remind us to delete the error types once the SDK is released?

ncordon commented 4 years ago

driver/driver.go, line 38 at r2 (raw file):


// ErrMissingDriver indicates that a driver image for the given language
// can not be found.

This is ultra peaky, but cannot instead of can not

ncordon commented 4 years ago

protocol/driver_test.go, line 69 at r2 (raw file):

  var cases = []driverMock{
      {name: "success", uast: defaultUAST()},
      {name: "partial parse", uast: defaultUAST(), err: driver.ErrSyntax.Wrap(errors.New("invalid source"))},

What is a partial parse?