bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkTypes.h" |
Mike Klein | 8f11d4d | 2018-01-24 12:42:55 -0500 | [diff] [blame] | 9 | #if defined(SK_BUILD_FOR_WIN) |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 10 | |
commit-bot@chromium.org | 8e13a15 | 2014-03-19 19:28:00 +0000 | [diff] [blame] | 11 | #include "SkHRESULT.h" |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 12 | |
bungeman@google.com | e4ae0bc | 2014-05-21 19:44:39 +0000 | [diff] [blame] | 13 | void SkTraceHR(const char* file, unsigned long line, HRESULT hr, const char* msg) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 14 | if (msg) { |
bungeman@google.com | e4ae0bc | 2014-05-21 19:44:39 +0000 | [diff] [blame] | 15 | SkDebugf("%s\n", msg); |
| 16 | } |
| 17 | SkDebugf("%s(%lu) : error 0x%x: ", file, line, hr); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 18 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 19 | LPSTR errorText = nullptr; |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 20 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 21 | FORMAT_MESSAGE_FROM_SYSTEM | |
| 22 | FORMAT_MESSAGE_IGNORE_INSERTS, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 23 | nullptr, |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 24 | hr, |
| 25 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 26 | (LPSTR) &errorText, |
| 27 | 0, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 28 | nullptr |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 29 | ); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 30 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 31 | if (nullptr == errorText) { |
bungeman@google.com | e4ae0bc | 2014-05-21 19:44:39 +0000 | [diff] [blame] | 32 | SkDebugf("<unknown>\n"); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 33 | } else { |
bungeman@google.com | e4ae0bc | 2014-05-21 19:44:39 +0000 | [diff] [blame] | 34 | SkDebugf("%s", errorText); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 35 | LocalFree(errorText); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 36 | errorText = nullptr; |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 37 | } |
| 38 | } |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 39 | |
Mike Klein | 8f11d4d | 2018-01-24 12:42:55 -0500 | [diff] [blame] | 40 | #endif//defined(SK_BUILD_FOR_WIN) |