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

Provide a version of openConnection that doesn't throw an exception #105

Open
mightybyte opened this issue May 30, 2017 · 1 comment
Open

Comments

@mightybyte
Copy link

I have an application where sometimes I expect the connection to not be available. It would be nice to have a function that returns a Maybe or Either instead of throwing an exception and printing an error message to the screen.

@istathar
Copy link
Member

istathar commented Jun 1, 2017

@mightybyte I had a look. My initial reaction was "sure", although I'd prefer to make a bigger change and smash the API in the process (if there are other things that need fixing that badly).

As I poked around, however, I realized that changing it this way just means me putting try or catch in there and then changing the signature to :: IO (Either e a) (or similar, whatever, ok), but which makes me ask... can't you just put try around your code calling openConnection to catch any exceptions coming out of there yourself?

Not saying this is ideal (I'm still on the fence about the Exceptions vs EitherT e IO a debate) but it would be doable for you now & without breaking / proliferating API. Am I missing something?

AfC

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

2 participants