source: branch_service/src/win32_exception.hpp @ 564

Revision 564, 1.1 KB checked in by Eoin, 11 years ago (diff)

Added win32_exception class.

Line 
1
2//         Copyright Eóin O'Callaghan 2008 - 2008.
3// Distributed under the Boost Software License, Version 1.0.
4//    (See accompanying file LICENSE_1_0.txt or copy at
5//          http://www.boost.org/LICENSE_1_0.txt)
6
7#pragma once
8
9#include "windows.h"
10#include <exception>
11
12class win32_exception: public std::exception
13{
14public:
15    typedef const void* Address; // OK on Win32 platform
16
17    static void install_handler();
18    virtual const char* what() const { return mWhat; };
19    Address where() const { return mWhere; };
20    unsigned code() const { return mCode; };
21protected:
22    win32_exception(const EXCEPTION_RECORD& info);
23    static void translate(unsigned code, EXCEPTION_POINTERS* info);
24private:
25    const char* mWhat;
26    Address mWhere;
27    unsigned mCode;
28};
29
30class access_violation: public win32_exception
31{
32public:
33    bool isWrite() const { return mIsWrite; };
34    Address badAddress() const { return mBadAddress; };
35private:
36    bool mIsWrite;
37    Address mBadAddress;
38    access_violation(const EXCEPTION_RECORD& info);
39    friend void win32_exception::translate(unsigned code, EXCEPTION_POINTERS* info);
40};
Note: See TracBrowser for help on using the repository browser.