Skip to content
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

More specific exception handling in Riak #51

Open
sanketr opened this issue Jul 9, 2016 · 1 comment
Open

More specific exception handling in Riak #51

sanketr opened this issue Jul 9, 2016 · 1 comment

Comments

@sanketr
Copy link

sanketr commented Jul 9, 2016

Folks,

It seems that RiakException constructor doesn't expose the sub-types of exceptions. There is really no good way to do a user-friendly error handling if we don't know what sub-type of exception this is. For example, given TypeException, I could tell the user that the requested data doesn't exist. NetException on the other hand is some kind of outage message in my case. This is very, very useful, and so, will really appreciate exposing the constructors. This is my current exception handling code - will like to be able to pattern match on RiakException and do appropriate error handling instead of using RiakException show:

procRiakException :: SomeException -> Maybe RiakException
procRiakException = fromException

procException :: SomeException -> (Int,T.Text)
procException e = case (procRiakException e) of
  Just ex -> (2, T.pack . show $ ex)
  Nothing -> (1, T.pack . displayException $ e)
@sanketr sanketr changed the title Exception handling in Riak More specific exception handling in Riak Jul 9, 2016
@sanketr
Copy link
Author

sanketr commented Jul 10, 2016

On further investigation, it seems that ErrorResponse is where the Riak exceptions are handled. It is defined as Exception elsewhere but not exported. So, probably this is the correct exception to look at for making visible to users of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant