go-imap icon indicating copy to clipboard operation
go-imap copied to clipboard

error status response transparency

Open kompiuter opened this issue 5 years ago • 3 comments

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.

kompiuter avatar Jun 10 '19 06:06 kompiuter

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.

foxcpp avatar Jun 10 '19 10:06 foxcpp

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.

foxcpp avatar Jun 10 '19 11:06 foxcpp

Good suggestion. If I have some spare time I'll familiarize myself with the codebase more and create a PR.

kompiuter avatar Jun 10 '19 11:06 kompiuter

Done in v2.

emersion avatar Mar 17 '23 23:03 emersion