I’m just starting with nameko but can’t seem to find docs or examples for passing exceptions back from the service to the client.
The service has a method which ultimately determines a problem. In this case, the problem is that it found more than one match for a user-provided data when the key is supposed to be unique. The user can correct this by choosing the intended key from the list of keys found, so the function throws an exception indicating the issue and includes the keys found and the user-provided data for context. Clients should catch this exception, present the user with the list of keys and a prompt to select just one. Once selected the rpc call should re-try the request.
I don’t quite know how to pass the data back on exception. The client gets a RemoteError which contains the name of the exception, but no data. I’ve tried using a worker_result dependency provider, but there isn’t a way to alter the result sent back to include the list of found keys.
Is it better to not throw an exception and instead return some kind of error state as the response? Does this mean having to return error state on each method to indicate the mode of the response?
How do others send contextualized error responses back from remote calls?