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" |
| 9 | |
commit-bot@chromium.org | 8e13a15 | 2014-03-19 19:28:00 +0000 | [diff] [blame] | 10 | #include "SkHRESULT.h" |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 11 | |
| 12 | void SkTraceHR(const char* file, unsigned long line, |
| 13 | HRESULT hr, const char* msg) { |
tomhudson@google.com | 7558925 | 2012-04-10 17:42:21 +0000 | [diff] [blame] | 14 | SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg))); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 15 | SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr)); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 16 | |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 17 | LPSTR errorText = NULL; |
| 18 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 19 | FORMAT_MESSAGE_FROM_SYSTEM | |
| 20 | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 21 | NULL, |
| 22 | hr, |
| 23 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 24 | (LPSTR) &errorText, |
| 25 | 0, |
| 26 | NULL |
| 27 | ); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 28 | |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 29 | if (NULL == errorText) { |
| 30 | SkDEBUGF(("<unknown>\n")); |
| 31 | } else { |
commit-bot@chromium.org | 9711e44 | 2013-04-24 20:03:00 +0000 | [diff] [blame] | 32 | SkDEBUGF(("%s", errorText)); |
bungeman@google.com | b29c883 | 2011-10-10 13:19:10 +0000 | [diff] [blame] | 33 | LocalFree(errorText); |
| 34 | errorText = NULL; |
| 35 | } |
| 36 | } |