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

Add getLastErrno and use it where appropriate #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anacrolix
Copy link
Contributor

I've added a new error type, SessionError, which includes additional information that's available when the libssh2_session_* functions fail. It was very helpful diagnosing failures in my use of direct_tcpip, which without this only reported CHANNEL_FAILURE, and there was a lot more info in the string. Additionally I think this might provide a very minor performance gain, as EAGAINs won't trigger allocation of storage for the string that is thrown away anyway.

This change may have a slight API change to users, they might be expecting ErrorCode to be thrown and get SessionError instead for some calls. Perhaps there's a way to automatically convert SessionError => ErrorCode for those cases if you care. I'm not familiar with Haskell enough but would add it if possible.

I've also got an assert to ensure that the followup call to getLastError returns the same error as getLastErrno incase there's something racy going on, I don't know if that's best practice in Haskell.

@kvanbere
Copy link
Contributor

You can convert anything that used to expect an ErrorCode to instead expect a constraint and then use a common type class to make it transparent whichever kind gets returned.

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

Successfully merging this pull request may close these issues.

2 participants