convert Structured Exception Code to string

原创 2013年12月02日 21:29:19
#include <stdio.h>
#include <windows.h> // for EXCEPTION_ACCESS_VIOLATION
#include <excpt.h>

char const* exCode2ExDesc(unsigned int exCode)
{
	switch (exCode)
	{
	case EXCEPTION_ACCESS_VIOLATION:
		return "EXCEPTION_ACCESS_VIOLATION";
	case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
		return "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
	case EXCEPTION_BREAKPOINT:
		return "EXCEPTION_BREAKPOINT";
	case EXCEPTION_DATATYPE_MISALIGNMENT:
		return "EXCEPTION_DATATYPE_MISALIGNMENT";
	case EXCEPTION_FLT_DENORMAL_OPERAND:
		return "EXCEPTION_FLT_DENORMAL_OPERAND";
	case EXCEPTION_FLT_DIVIDE_BY_ZERO:
		return "EXCEPTION_FLT_DIVIDE_BY_ZERO";
	case EXCEPTION_FLT_INEXACT_RESULT:
		return "EXCEPTION_FLT_INEXACT_RESULT";
	case EXCEPTION_FLT_INVALID_OPERATION:
		return "EXCEPTION_FLT_INVALID_OPERATION";
	case EXCEPTION_FLT_OVERFLOW:
		return "EXCEPTION_FLT_OVERFLOW";
	case EXCEPTION_FLT_STACK_CHECK:
		return "EXCEPTION_FLT_STACK_CHECK";
	case EXCEPTION_FLT_UNDERFLOW:
		return "EXCEPTION_FLT_UNDERFLOW";
	case EXCEPTION_GUARD_PAGE:
		return "EXCEPTION_GUARD_PAGE";
	case EXCEPTION_ILLEGAL_INSTRUCTION:
		return "EXCEPTION_ILLEGAL_INSTRUCTION";
	case EXCEPTION_IN_PAGE_ERROR:
		return "EXCEPTION_IN_PAGE_ERROR";
	case EXCEPTION_INT_DIVIDE_BY_ZERO:
		return "EXCEPTION_INT_DIVIDE_BY_ZERO";
	case EXCEPTION_INT_OVERFLOW:
		return "EXCEPTION_INT_OVERFLOW";
	case EXCEPTION_INVALID_DISPOSITION:
		return "EXCEPTION_INVALID_DISPOSITION";
	case EXCEPTION_INVALID_HANDLE:
		return "EXCEPTION_INVALID_HANDLE";
	case EXCEPTION_NONCONTINUABLE_EXCEPTION:
		return "EXCEPTION_NONCONTINUABLE_EXCEPTION";
	case EXCEPTION_PRIV_INSTRUCTION:
		return "EXCEPTION_PRIV_INSTRUCTION";
	case EXCEPTION_SINGLE_STEP:
		return "EXCEPTION_SINGLE_STEP";
	case EXCEPTION_STACK_OVERFLOW:
		return "EXCEPTION_STACK_OVERFLOW";
	case  STATUS_UNWIND_CONSOLIDATE:
		return "STATUS_UNWIND_CONSOLIDATE";
	default:
		return "UNKNOWN_SE_EXCEPTION";
	}

}

int main()
{
	int * p = 0;
	__try
	{

		*p = 13;    // causes an access violation exception;	
	}
	__except (EXCEPTION_EXECUTE_HANDLER)
	{
		puts(exCode2ExDesc(GetExceptionCode()));
	}
	return 0;
}

相关文章推荐

STL std:string引起的User breakpoint exception/User breakpoint called from code at

STL std:string引起的User breakpoint exception/User breakpoint called from code at ...
  • lionzl
  • lionzl
  • 2011年07月05日 15:54
  • 520

Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx'

今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.co...

《leetCode》:Convert String to Integer

题目描述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cas...

[转]STL std:string引起的User breakpoint exception/User breakpoint called from code at

SYMPTOMS:  程序崩溃,弹出 User breakpoint called from code at 0x????????对话框;  崩溃时的调用栈有如下几种常见情形: (1) TDL...

svn locale Can't convert string from native encoding to 'UTF-8'

简单备忘:svn 提交代码报错,编码问题

svn: Can't convert string from 'UTF-8' to native encoding 的解决办法

http://www.leakon.com/archives/610  svn 版本库中有文件是以中文字符命名的,在 Linux 下 checkout 会报错: svn: Can't co...

experiment : convert a string to crc32

今天工作任务中遇到一个分支任务, 从系统上层传来一个GUID样子的系统内唯一标识用的字符串, 传到驱动后, 只接受一个DWORD值. 想想需要将这个字符串变成DWORD, 那CRC32好了. ...

Spring3MVC 提交请求参数中的日期问题(java.lang.String cant not convert to java.util.Date)

Spring3MVC中Controller层接受前端页面的参数有一种情况: @RequestMapping(value = "/updateStudent.do") public ModelAnd...
  • thc1987
  • thc1987
  • 2012年01月17日 15:47
  • 6296

Can't convert boolean to string automatically, because the "boolean_format" setting was "true,false"

五月 11, 2017 5:06:50 下午 freemarker.log._JULLoggerFactory$JULLogger error 严重: Error executing FreeMark...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:convert Structured Exception Code to string
举报原因:
原因补充:

(最多只允许输入30个字)