michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: #include "SkHRESULT.h" michael@0: michael@0: void SkTraceHR(const char* file, unsigned long line, michael@0: HRESULT hr, const char* msg) { michael@0: SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg))); michael@0: SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr)); michael@0: michael@0: LPSTR errorText = NULL; michael@0: FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | michael@0: FORMAT_MESSAGE_FROM_SYSTEM | michael@0: FORMAT_MESSAGE_IGNORE_INSERTS, michael@0: NULL, michael@0: hr, michael@0: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), michael@0: (LPSTR) &errorText, michael@0: 0, michael@0: NULL michael@0: ); michael@0: michael@0: if (NULL == errorText) { michael@0: SkDEBUGF(("\n")); michael@0: } else { michael@0: SkDEBUGF(("%s", errorText)); michael@0: LocalFree(errorText); michael@0: errorText = NULL; michael@0: } michael@0: }