Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Win32Exception.h

Go to the documentation of this file.
00001 /*  Win32Exception.h - Handy exception object that is capable
00002     of calling FormatMessage for sensible API error reporting.
00003 
00004     Copyright (C) 2001-2004 Mark Weaver
00005     Written by Mark Weaver <mark@npsl.co.uk>
00006 
00007     Part of the Open-Win32 library.
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public
00019     License along with this library; if not, write to the
00020     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021     Boston, MA  02111-1307, USA.
00022 */
00023 
00028 #ifndef OW32_Win32Exception_h
00029 #define OW32_Win32Exception_h
00030 
00031 #include <OW32/windows.h>
00032 #include <OW32/tstl.h>
00033 #include <OW32/OW32Libs.h>
00034 #include <string>
00035 
00036 namespace OW32
00037 {
00038 
00042 class OW32_LIB_EXPORT CWin32Exception
00043 {
00044 public:
00051     CWin32Exception(LPCTSTR prefix, DWORD error) :
00052         m_prefix(prefix),
00053         m_error(error)
00054     {
00055     }
00056 
00060     CWin32Exception() :
00061         m_error(ERROR_SUCCESS)
00062     {
00063     }
00064 
00068     DWORD getError() const
00069     {
00070         return m_error;
00071     }
00072 
00076     LPCTSTR getPrefix() const
00077     {
00078         return m_prefix.c_str();
00079     }
00080 
00084     std::_tstring getFormattedError() const;
00085 
00090     static std::_tstring getFormattedError(DWORD error, LPCTSTR prefix)
00091     {
00092         CWin32Exception e(prefix, error);
00093         return e.getFormattedError();
00094     }
00095 
00096 private:
00097     DWORD           m_error;
00098     std::_tstring   m_prefix;
00099 };
00100 
00101 } // namespace OW32
00102 
00103 #endif // OW32_Win32Exception_h

Generated on Sun Jun 5 01:29:18 2005 for OW32 by  doxygen 1.3.9.1