mirror of
https://github.com/golang/go
synced 2024-11-25 08:57:58 -07:00
syscall: attempt to find error message in "local" language before resorting to error number on windows
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6499121
This commit is contained in:
parent
218f08a987
commit
6e4d24999f
@ -84,10 +84,11 @@ 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 {
|
||||||
// TODO(brainman): Call FormatMessage again asking for "native" error message.
|
n, err = FormatMessage(flags, 0, uint32(e), 0, b, nil)
|
||||||
// http://code.google.com/p/go/issues/detail?id=3376 must be resolved first.
|
if err != nil {
|
||||||
return "winapi error #" + itoa(int(e))
|
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