1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
7 * Hook IfFailThrow calls to do some logging when exceptions are thrown.
15 #define IfFailThrow(x) \
17 HRESULT hrMacro = x; \
18 if (FAILED(hrMacro)) { \
19 /* don't embed file names in retail to save space and avoid IP */ \
20 /* a findstr /n will allow you to locate it in a pinch */ \
21 ThrowAndLog(hrMacro, INDEBUG_COMMA(#x) INDEBUG_COMMA(__FILE__) __LINE__); \
25 inline void ThrowAndLog(HRESULT hr, INDEBUG_COMMA(__in_z const char * szMsg) INDEBUG_COMMA(__in_z const char * szFile) int lineNum)
29 // Log failures when StressLog is on
30 static ConfigDWORD g_iStressLog;
31 BOOL bLog = g_iStressLog.val_DontUse_(CLRConfig::UNSUPPORTED_StressLog, 0);
35 GetSvcLogger()->Printf("IfFailThrow about to throw in file %s line %d, msg = %s, hr: 0x%X\n", szFile, lineNum, szMsg, hr);
37 GetSvcLogger()->Printf("IfFailThrow about to throw on line %d. hr: 0x%X\n", lineNum, hr);
44 #endif // __ZAPLOG_H__