WPILib 2012
WPILibRoboticsLibraryforFRC
Error.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef _ERROR_H
00008 #define _ERROR_H
00009 
00010 #include "Base.h"
00011 #include "ChipObject/NiRio.h"
00012 #include <string>
00013 #include <vxWorks.h>
00014 
00015 //  Forward declarations
00016 class ErrorBase;
00017 
00021 class Error
00022 {
00023 public:
00024         typedef tRioStatusCode Code;
00025 
00026         Error();
00027         ~Error();
00028         void Clone(Error &error);
00029         Code GetCode() const;
00030         const char *GetMessage() const;
00031         const char *GetFilename() const;
00032         const char *GetFunction() const;
00033         UINT32 GetLineNumber() const;
00034         const ErrorBase* GetOriginatingObject() const;
00035         double GetTime() const;
00036         void Clear();
00037         void Set(Code code, const char* contextMessage, const char* filename,
00038                 const char *function, UINT32 lineNumber, const ErrorBase* originatingObject);
00039         static void EnableStackTrace(bool enable) { m_stackTraceEnabled=enable; }
00040         static void EnableSuspendOnError(bool enable) { m_suspendOnErrorEnabled=enable; }
00041 
00042 private:
00043         void Error::Report();
00044 
00045         Code m_code;
00046         std::string m_message;
00047         std::string m_filename;
00048         std::string m_function;
00049         UINT32 m_lineNumber;
00050         const ErrorBase* m_originatingObject;
00051         double m_timestamp;
00052 
00053         static bool m_stackTraceEnabled;
00054         static bool m_suspendOnErrorEnabled;
00055         DISALLOW_COPY_AND_ASSIGN(Error);
00056 };
00057 
00058 #endif
00059 
 All Classes Functions Variables