0

Is there an API for translating ExceptionCode:s in an ExceptionRecord to a readable message like FormatMessage for regular errors.

user877329
  • 6,717
  • 8
  • 46
  • 88
  • Yes, FormatMessage(). Exception codes are however typically native operating system error codes, not winapi error codes. So you'll need the FORMAT_MESSAGE_FROM_HMODULE and pass the module handle you get from GetModuleHandle(L"ntdll.dll"). The required FORMAT_MESSAGE_IGNORE_INSERTS option is however troublesome. – Hans Passant Aug 18 '13 at 15:54

1 Answers1

0

There is no built-in function for this.

Many people are doing it manually:

fostlib::exceptions::structured::structured in: http://svn.felspar.com/public/fost-base/tags/4.12.12.44490/fost-base/Cpp/fost-core/exception-win.cpp

MyUnHandledExceptionFilter in: http://openholdembot.googlecode.com/svn/trunk/ManualMode/debug.cpp

GetExceptionString in: http://subversion.assembla.com/svn/ub-source113/Standard%20Gaming%20Platform/ExceptionHandling.cpp

Mike Weir
  • 3,094
  • 1
  • 30
  • 46
  • Or some code generation #!/bin/sh echo "const size_t N_MESSAGES=$(grep 'STATUS_' 'D:\bin-win64\mingw64\x86_64-w64-mingw32\include\winnt.h'|wc -l);">> seh.stub echo "ExceptionName exceptions[]=" >>seh.stub echo " {" >>seh.stub grep "STATUS_" "D:\bin-win64\mingw64\x86_64-w64-mingw32\include\winnt.h"\ |sed 's/#define \(.*\) ((DWORD)\(.*\))/\t{\2,STR("\1")},/g'|sort >> seh.stub echo " };" >>seh.stub – user877329 Aug 18 '13 at 18:23