-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error handling #170
Comments
@praveenperera would you still like to contribute with this? I think this approach is good and we can accompany it with a |
Another possible solution is to just document the status atoms better |
Hi @polvalente, Do you think its enough adding an ASCII table in the
Would it be better to include it in the |
@hackvan I think that's perfect. We can put that in |
I think we could provide this macro in GRPC.RPCError together with the better documentation: defmacro is_rpc_error(e, status) when is_struct(e, GRPC.RPCError) and e.status == status Which would make it easier for users to pattern match on different error types without the hassle of dealing with many different kinds of structs |
Adds a markdown table to detail each code status and its related message. Closes elixir-grpc#170
For this I don't get it what is the purpose or a case use for this macro 😅 |
That looks good, but I'd format it with a markdown table so ex doc renders it nicely. The guard (I wrote defmacro but should have been defguard there) covers the use case mentioned in the issue body itself, where instead of having different structs for pattern matching, we can just use the guard for matching on different errors |
Ok, I get it but in this case when the people need to use the |
Yes. Or require it. But that's a lot more manageable than aliasing N different structs |
* Docs: Improves the module docs for error statuses. Adds a markdown table to detail each code status and its related message. Closes #170 * Docs: Updates the reference link to see more details about GRPC status code * Feat: Adds `is_rpc_error/2` guard clause to check if it's an RPCError struct Fix and add some missing specs. * Test: Add GRPC.Status and GRPC.RPCError unit tests * Fix: Applies suggestions from the code review * Adds examples about `is_rpc_error/2` clause in `GRPC.RPCError` module doc. * Improves @SPEC with variable names. * Renames error_test.exs to rpc_error_test.exs file. * Fixes markdown table syntax in `GRPC.Status` module doc. * Fix: Use `mix format` on status_test.exs file * Test: Refactor tests related to the expected status code and expected error message using a common factory function. * update ex_doc and some formatting * docs: improve docs for error handling * test: improve testing * dialyzer --------- Co-authored-by: Paulo Valente <16843419+polvalente@users.noreply.github.com>
I think the error handling good be improved a little bit. Instead of always returning the same
RPCError
struct we could pattern match on the status code and return different errors. Currently I'm doing it like below. If you like this approach I could do a PR:The text was updated successfully, but these errors were encountered: