tException.h
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
2 // This file is part of FZIs ic_workspace.
3 //
4 // This program is free software licensed under the LGPL
5 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
6 // You can find a copy of this license in LICENSE folder in the top
7 // directory of the source code.
8 //
9 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
10 //
11 // -- END LICENSE BLOCK ------------------------------------------------
12 
13 // ----------------------------------------------------------
14 /*
15  * tException
16  * icl_hardware
17  *
18  * Created by Hugo Ritzkowski on 2012-02-07.
19  * Copyright 2012
20  * Company Forschungszentrum Informatik (FZI), Abteilung IDS.
21  * All rights reserved.
22  *
23  */
24 // ----------------------------------------------------------
33 // ----------------------------------------------------------
34 
35 #ifndef ICL_HARDWARE_TEXCEPTION_H
36 #define ICL_HARDWARE_TEXCEPTION_H
37 
38 #include <string>
39 #include <exception>
40 
41 namespace icl_hardware
42 {
43 namespace can
44 {
47 {
53 };
54 
55 class tException : public std::exception
56 {
57 public:
59  tException(Hardware_Exception exception, const std::string &_description)
60  : description(_description),
61  error_code(exception)
62  {};
63 
66  : error_code(exception)
67  {
68  switch(exception)
69  {
70  case eHARDWARE_ERROR:
71  {
72  this->description = "Hardware error.";
73  break;
74  }
75  case ePEAK_DEVICE_ERROR:
76  {
77  this->description = "Problem with Peak-Can-Device.";
78  break;
79  }
80  case eTHREAD_ERROR:
81  {
82  this->description = "Thread unscheduled terminated.";
83  }
84  case eMESSAGE_ERROR:
85  {
86  this->description = "Empty message received.";
87  }
88  case eFILE_ERROR:
89  {
90  this->description = "Error while writing to file.";
91  }
92  }
93  };
94 
96  ~tException() throw()
97  {};
98 
100  virtual const char* what() const throw()
101  {
102  return description.c_str();
103  }
104 
106  inline std::string GetDescription()
107  {
108  return description;
109  };
110 
113  {
114  return error_code;
115  };
116 
117 protected:
119  std::string description;
120 
123 };
124 } /* can */
125 } /* icl_hardware */
126 #endif // ICL_HARDWARE_TEXCEPTION_H
tException(Hardware_Exception exception)
Definition: tException.h:65
Hardware_Exception GetErrorCode()
Definition: tException.h:112
Hardware_Exception error_code
Definition: tException.h:122
tException(Hardware_Exception exception, const std::string &_description)
Definition: tException.h:59
virtual const char * what() const
Definition: tException.h:100


fzi_icl_can
Author(s):
autogenerated on Mon Jun 10 2019 13:17:02