error.h

Go to the documentation of this file.
00001 
00002 //**************************************************************************/
00003 // Copyright (c) 2008 Autodesk, Inc.
00004 // All rights reserved.
00005 //
00006 // Use of this software is subject to the terms of the Autodesk license
00007 // agreement provided at the time of installation or download, or which
00008 // otherwise accompanies this software in either electronic or hard copy form.
00009 //
00010 //**************************************************************************/
00011 // DESCRIPTION:
00012 // CREATED: October 2008
00013 //**************************************************************************/
00014 
00015 #include <QtCore/QCoreApplication>
00016 
00017 namespace mudbox {
00046 class MBDLL_DECL Error
00047 {
00048     Q_DECLARE_TR_FUNCTIONS(mudbox::Error);
00049 
00050 protected:
00051     QString m_sErrorMessage;
00052     bool m_bOnHeap;
00053     const char *m_pFunction, *m_pSource;
00054     unsigned int m_iLine;
00055 
00056 public:
00057     enum Code
00058     {
00059         codeOk,
00060         codeOutOfMemory,
00061         codeHardwareFailure,
00062         codeOutOfVideoMemory,
00063         codeUnspecified,
00064         codeUserSkip,
00065         codeUserIgnore,
00066         codeUserCancel,
00067         codeUnknown = 0xffffffff
00068     } m_eCode;
00069 
00070 private:
00071     Error( const QString &sMessage, bool bOnHeap, Code eCode = codeUnspecified );
00072 
00073 public:
00080     Error(
00081         const QString &sMessage,                
00082         Code eCode = codeUnspecified,       
00083         const char *pFunction = 0,          
00084         const char *pSourceFileName = 0,    
00085         unsigned int iLine = 0              
00086         );
00087 
00090     Error *Format( const QString &sMessage );
00091 
00093     enum Code Code( void ) const;
00094 
00096     const QString &Message( void ) const;
00097 
00104     void Report(
00105         const QString &sPre = ""        
00106         ) const;
00107 
00109     void Discard( void ) const;
00110 
00112     static void ThrowBadAlloc( void ) { throw &s_cBadAlloc; };
00113 
00114     static Error s_cBadAlloc;
00115 };
00116 
00117 }; // end of namespace mudbox
00118