mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #30136 from tg123/master
Windows: return err instead of panic when convert string to utf16
This commit is contained in:
commit
d38753303a
1 changed files with 7 additions and 1 deletions
|
@ -148,7 +148,13 @@ func callEventRegister() error {
|
|||
}
|
||||
|
||||
func callEventWriteString(message string) error {
|
||||
ret, _, _ := procEventWriteString.Call(uintptr(providerHandle), 0, 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(message))))
|
||||
utf16message, err := syscall.UTF16FromString(message)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ret, _, _ := procEventWriteString.Call(uintptr(providerHandle), 0, 0, uintptr(unsafe.Pointer(&utf16message[0])))
|
||||
if ret != win32CallSuccess {
|
||||
errorMessage := fmt.Sprintf("ETWLogs provider failed to log message. Error: %d", ret)
|
||||
logrus.Error(errorMessage)
|
||||
|
|
Loading…
Reference in a new issue