blob: 74b13ebb4bd674ff5a51c4276ce67b1721146365 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#ifndef _ERROR_H
8#define _ERROR_H
9
10#include "Base.h"
11#include "ChipObject/NiRio.h"
12#include <string>
13#include <vxWorks.h>
14
15// Forward declarations
16class ErrorBase;
17
18/**
19 * Error object represents a library error.
20 */
21class Error
22{
23public:
24 typedef tRioStatusCode Code;
25
26 Error();
27 ~Error();
28 void Clone(Error &error);
29 Code GetCode() const;
30 const char *GetMessage() const;
31 const char *GetFilename() const;
32 const char *GetFunction() const;
33 UINT32 GetLineNumber() const;
34 const ErrorBase* GetOriginatingObject() const;
35 double GetTime() const;
36 void Clear();
37 void Set(Code code, const char* contextMessage, const char* filename,
38 const char *function, UINT32 lineNumber, const ErrorBase* originatingObject);
39 static void EnableStackTrace(bool enable) { m_stackTraceEnabled=enable; }
40 static void EnableSuspendOnError(bool enable) { m_suspendOnErrorEnabled=enable; }
41
42private:
43 void Report();
44
45 Code m_code;
46 std::string m_message;
47 std::string m_filename;
48 std::string m_function;
49 UINT32 m_lineNumber;
50 const ErrorBase* m_originatingObject;
51 double m_timestamp;
52
53 static bool m_stackTraceEnabled;
54 static bool m_suspendOnErrorEnabled;
55 DISALLOW_COPY_AND_ASSIGN(Error);
56};
57
58#endif
59