WPILibC++  unspecified
Error.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 FIRST. 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 <stdint.h>
11 
12 #include <string>
13 
14 #include <llvm/StringRef.h>
15 #include <llvm/Twine.h>
16 
17 #ifdef _WIN32
18 #include <Windows.h>
19 // Windows.h defines #define GetMessage GetMessageW, which we don't want.
20 #undef GetMessage
21 #endif
22 
23 #include "Base.h"
24 
25 namespace frc {
26 
27 class ErrorBase;
28 
32 class Error {
33  public:
34  typedef int Code;
35 
36  Error() = default;
37 
38  Error(const Error&) = delete;
39  Error& operator=(const Error&) = delete;
40 
41  void Clone(const Error& error);
42  Code GetCode() const;
43  std::string GetMessage() const;
44  std::string GetFilename() const;
45  std::string GetFunction() const;
46  int GetLineNumber() const;
47  const ErrorBase* GetOriginatingObject() const;
48  double GetTimestamp() const;
49  void Clear();
50  void Set(Code code, const llvm::Twine& contextMessage,
51  llvm::StringRef filename, llvm::StringRef function, int lineNumber,
52  const ErrorBase* originatingObject);
53 
54  private:
55  void Report();
56 
57  Code m_code = 0;
58  std::string m_message;
59  std::string m_filename;
60  std::string m_function;
61  int m_lineNumber = 0;
62  const ErrorBase* m_originatingObject = nullptr;
63  double m_timestamp = 0.0;
64 };
65 
66 } // namespace frc
Definition: RobotController.cpp:14
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
Base class for most objects.
Definition: ErrorBase.h:74
Error object represents a library error.
Definition: Error.h:32
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42