go-imap
go-imap copied to clipboard
error status response transparency
There's a StatusResp defining the status response type and code as defined in RFC 3501 section 7.1.
I'd like to see the code returned when client.Select fails. Currently the status code response is lost using .Err() (which creates a new error containing the status info), thus there's no proper way to deduce the response code.
A better approach might be to return StatusResp
directly (by implementing the Error
interface) and allow callers to make a type assertion? Just thinking out loud.
Note that StatusResp is not necessarily an error. Returning OK response as an error would be strange, don't you think? I think we might want to preserve Err() method but create ErrResp type and make Err() method turn StatusResp into either nil or *ErrResp depending on contents.
In any case - PRs are welcome.
Also, it might worth considering checking for ErrResp when it is returned by server backend. It can be useful for go-imap-proxy, for example.
Good suggestion. If I have some spare time I'll familiarize myself with the codebase more and create a PR.
Done in v2.