WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Error.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "Base.h"
11 
12 #ifdef _WIN32
13  #include <Windows.h>
14  //Windows.h defines #define GetMessage GetMessageW, which is stupid and we don't want it.
15  #undef GetMessage
16 #endif
17 
18 #include <string>
19 #include <stdint.h>
20 #include "llvm/StringRef.h"
21 
22 // Forward declarations
23 class ErrorBase;
24 
28 class Error {
29  public:
30  typedef int32_t Code;
31 
32  Error() = default;
33 
34  Error(const Error&) = delete;
35  Error& operator=(const Error&) = delete;
36 
37  void Clone(const Error& error);
38  Code GetCode() const;
39  std::string GetMessage() const;
40  std::string GetFilename() const;
41  std::string GetFunction() const;
42  uint32_t GetLineNumber() const;
43  const ErrorBase* GetOriginatingObject() const;
44  double GetTimestamp() const;
45  void Clear();
46  void Set(Code code, llvm::StringRef contextMessage,
47  llvm::StringRef filename, llvm::StringRef function,
48  uint32_t lineNumber, const ErrorBase* originatingObject);
49 
50  private:
51  void Report();
52 
53  Code m_code = 0;
54  std::string m_message;
55  std::string m_filename;
56  std::string m_function;
57  uint32_t m_lineNumber = 0;
58  const ErrorBase* m_originatingObject = nullptr;
59  double m_timestamp = 0.0;
60 };
Error object represents a library error.
Definition: Error.h:28
Base class for most objects.
Definition: ErrorBase.h:66
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:39