blob: 111cb761bdcce34fc5f118e4dea07157bb0f7308 [file] [log] [blame]
bungeman@google.comb29c8832011-10-10 13:19:10 +00001/*
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.org8e13a152014-03-19 19:28:00 +000010#include "SkHRESULT.h"
bungeman@google.comb29c8832011-10-10 13:19:10 +000011
12void SkTraceHR(const char* file, unsigned long line,
13 HRESULT hr, const char* msg) {
tomhudson@google.com75589252012-04-10 17:42:21 +000014 SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg)));
bungeman@google.comb29c8832011-10-10 13:19:10 +000015 SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr));
rmistry@google.comd6176b02012-08-23 18:14:13 +000016
bungeman@google.comb29c8832011-10-10 13:19:10 +000017 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.comd6176b02012-08-23 18:14:13 +000028
bungeman@google.comb29c8832011-10-10 13:19:10 +000029 if (NULL == errorText) {
30 SkDEBUGF(("<unknown>\n"));
31 } else {
commit-bot@chromium.org9711e442013-04-24 20:03:00 +000032 SkDEBUGF(("%s", errorText));
bungeman@google.comb29c8832011-10-10 13:19:10 +000033 LocalFree(errorText);
34 errorText = NULL;
35 }
36}