mirror of
https://github.com/golang/go
synced 2024-11-15 11:40:35 -07:00
[release-branch.go1] syscall: simplify text returned by Errno.Error() when FormatMessage fails
««« backport ac7250065a04 syscall: simplify text returned by Errno.Error() when FormatMessage fails Fixes #3623. R=golang-dev, bsiegert, rsc CC=golang-dev https://golang.org/cl/6218072 »»»
This commit is contained in:
parent
920ebab03c
commit
6835ec91dd
@ -90,7 +90,9 @@ func (e Errno) Error() string {
|
|||||||
b := make([]uint16, 300)
|
b := make([]uint16, 300)
|
||||||
n, err := FormatMessage(flags, 0, uint32(e), langid(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
|
n, err := FormatMessage(flags, 0, uint32(e), langid(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "error " + itoa(int(e)) + " (FormatMessage failed with err=" + itoa(int(err.(Errno))) + ")"
|
// TODO(brainman): Call FormatMessage again asking for "native" error message.
|
||||||
|
// http://code.google.com/p/go/issues/detail?id=3376 must be resolved first.
|
||||||
|
return "winapi error #" + itoa(int(e))
|
||||||
}
|
}
|
||||||
// trim terminating \r and \n
|
// trim terminating \r and \n
|
||||||
for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
|
for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
|
||||||
|
Loading…
Reference in New Issue
Block a user