frequenz-floss / frequenz-client-base-python

Base gRPC client
https://frequenz-floss.github.io/frequenz-client-base-python/
MIT License
0 stars 3 forks source link

Add client exceptions #55

Closed llucax closed 3 months ago

llucax commented 3 months ago

Add a ApiClientError exception that is the base class for all client exceptions. This exception is raised when there is an error in the client. We also wrap all gRPC response errors in a GrpcError exception that is a subclass of ApiClientError, and add one subclass for each possible gRPC status code.

This makes error handling more pythonic, as one can now just catch the exception type one is interested in, without having to do a second-level matching using the status.

It also helps avoiding to expose the grpclib classes to the user.

llucax commented 3 months ago

This is a port of:

With the following changes: