errorprint.cpp revision a126a5a0d184e3245a585414758011d1d095b35f
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * MS COM / XPCOM Abstraction Layer:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Error info print helpers. This implements the shared code from the macros from errorprint.h.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Copyright (C) 2009 Oracle Corporation
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * This file is part of VirtualBox Open Source Edition (OSE), as
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * available from http://www.virtualbox.org. This file is free software;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * you can redistribute it and/or modify it under the terms of the GNU
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * General Public License (GPL) as published by the Free Software
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Foundation, in version 2 as it comes in the "COPYING" file of the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappanvoid GluePrintErrorInfo(com::ErrorInfo &info)
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan Utf8Str str = Utf8StrFmt("ERROR: %ls\n"
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan "Details: code %Rhrc (0x%RX32), component %ls, interface %ls, callee %ls\n"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // print and log
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetovoid GluePrintErrorContext(const char *pcszContext, const char *pcszSourceFile, uint32_t ulLine)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // pcszSourceFile comes from __FILE__ macro, which always contains the full path,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // which we don't want to see printed:
7145ae3ec9b6b40ec13b508a7bb1718ce67f4588Nattuvetty Bhavyan Utf8Str strFilename(RTPathFilename(pcszSourceFile));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto Utf8Str str = Utf8StrFmt("Context: \"%s\" at line %d of file %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // print and log
716c180559045549271833327182dc6a266134f1Nattuvetty Bhavyan Utf8Str str = Utf8StrFmt("ERROR: code %Rhra (extended info not available)\n", rc);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // print and log
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto // if we have full error info, print something nice, and start with the actual error message
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (info.isFullAvailable() || info.isBasicAvailable())
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto GluePrintErrorContext(pcszContext, pcszSourceFile, ulLine);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto} /* namespace com */