Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Several classes for exception handling

, 19 Jan 2002
C++ wrappers for stack trace, unhandled exception and win32 structured exceptions
exception_exe.zip
Exception.exe
Exception.pdb
exception_src.zip
Exception.dsp
Exception.dsw
Exception.plg
/*
 Copyright (c) 2001 
 Author: Konstantin Boukreev 
 E-mail: konstantin@mail.primorye.ru 
 Created: 27.12.2001 15:49:31
 Version: 1.0.0

 Permission to use, copy, modify, distribute and sell this software
 and its documentation for any purpose is hereby granted without fee,
 provided that the above copyright notice appear in all copies and
 that both that copyright notice and this permission notice appear
 in supporting documentation.  Konstantin Boukreev makes no representations
 about the suitability of this software for any purpose.
 It is provided "as is" without express or implied warranty.

*/

#ifndef _unhandled_report_21e1d9a1_0c5b_4e7f_b0a3_14671ef2f514
#define _unhandled_report_21e1d9a1_0c5b_4e7f_b0a3_14671ef2f514

#if _MSC_VER > 1000 
#pragma once
#endif // _MSC_VER > 1000

#include <iostream>

#include "exception_trap.h"
#include "sym_engine.h"
#include "se_translator.h"

struct unhandled_report
{
	std::ostream & m_os;

	unhandled_report(std::ostream & os = std::cout) : m_os(os) {}
	unhandled_report(const unhandled_report& p) : m_os(p.m_os) {}
	unhandled_report& operator = (const unhandled_report&) { return *this; }
	
	long operator () (EXCEPTION_POINTERS * pex) 
	{ 		
		m_os << "Unhandled exception " 
			 << se_translator::name(pex->ExceptionRecord->ExceptionCode)
			 << " (0x" << std::hex << pex->ExceptionRecord->ExceptionCode << ") at "
			 << "0x" << pex->ExceptionRecord->ExceptionAddress 
			 << std::dec << std::endl;

		m_os << "The stack trace: " << std::endl;
		sym_engine::stack_trace(m_os, pex->ContextRecord);
		
		return EXCEPTION_CONTINUE_SEARCH; 
	}
};

#endif //_unhandled_report_21e1d9a1_0c5b_4e7f_b0a3_14671ef2f514

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Konstantin Boukreev
Web Developer
Russian Federation Russian Federation
I am freelance programmer. About 3 years of experience in C++ and I would rather use ATL, STL, WTL but not MFC Smile | :) . Main backgrounds are Win32 API, COM and Networking. Now I am interested about AI (Neural Network, Fuzzy Logic and GA). Currently based in Vladivostok, Russia.

| Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 20 Jan 2002
Article Copyright 2002 by Konstantin Boukreev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid