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

EOF 问题 #50

Closed
z2n opened this issue Jun 24, 2019 · 3 comments
Closed

EOF 问题 #50

z2n opened this issue Jun 24, 2019 · 3 comments

Comments

@z2n
Copy link

z2n commented Jun 24, 2019

你好, 我遇到一个问题, Stream.Read 返回的 EOFerrors.WithStack 包装后 的, 导致和其他一些库使用时得到错误的判断,
如: reverseproxy.go
是设计有误, 还是我用的方法错了?

@xtaci
Copy link
Owner

xtaci commented Jun 24, 2019

你可以用 err.Cause()获得topmost error
https://godoc.org/github.com/pkg/errors#Cause

@z2n
Copy link
Author

z2n commented Jun 25, 2019

可是和其他接口合作时它们接收到一个非 EOF 错误, 就会做一些其他处理(比如 error 日志输出, 提前返回等).

如上面的 net/http/httputil/reverseproxy 在遇到非 EOF 错误时就会输出 error 日志, 继而 panic 根本没有机会获取 err.Cause().

@xtaci
Copy link
Owner

xtaci commented Jun 25, 2019

你可以wrap一下,接口桥接, 但reverseproxy直接判定io.EOF,可以说是相当大胆的写法。

@z2n z2n closed this as completed Jul 16, 2019
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