iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exceptions.H
Go to the documentation of this file.
1 /*! @file
2  @author Randolph Voorhies
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 #ifndef INCLUDE_NRT_CORE_UTIL_EXCEPTIONS_H
37 #define INCLUDE_NRT_CORE_UTIL_EXCEPTIONS_H
38 
40 #include <nrt/External/cereal/types/string.hpp>
41 
42 namespace nrt
43 {
44  namespace exception
45  {
46  //! Exception thrown by DynamicLoader
47  /*! \relates DynamicLoader */
49  {
50  public:
51  enum ErrorType
52  {
53  //! Some unkown error occured
55 
56  //! The shared object file could not be found
58 
59  //! The requested symbol within a shared object could not be found
61  };
62 
63  //! Construct from nothing - needed by serialization
64  DynamicLoaderException() throw();
65 
66  ~DynamicLoaderException() throw();
67 
68  //! Create an exception caused by a missing .so file
69  DynamicLoaderException(std::string const & soName, std::string const& err) throw();
70 
71  //! Create an exception caused by a missing symbol within a .so file
72  DynamicLoaderException(std::string const & soName, std::string const & symbolName,
73  std::string const& err) throw();
74 
75  //! Returns the name of the offending shared object file
76  std::string const & soName();
77 
78  //! Returns the name of the symbol that failed to load if this is a
79  //! SymbolNotFound exception. Empty string otherwise.
80  std::string const & symbolName();
81 
82  //! Returns the error reported by dlload or dllopen
83  std::string const & err();
84 
85  //! Get the type of error
86  ErrorType error();
87 
88  protected:
89  friend class cereal::access;
90 
91  //! Serialization
92  template <class Archive> void serialize(Archive & ar)
93  { ar(cereal::base_class<SerializableException>(this), itsErrorType, itsSoName, itsSymbolName, itsErr); }
94 
95  private:
96  ErrorType itsErrorType;
97  std::string itsSoName;
98  std::string itsSymbolName;
99  std::string itsErr;
100  };
101  }
102 }
103 
104 #endif // INCLUDE_NRT_CORE_UTIL_EXCEPTIONS_H