NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
error.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013, Regents of the University of California
4  * Alexander Afanasyev
5  *
6  * BSD license, See the LICENSE file for more information
7  *
8  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
9  */
10 
30 #ifndef NDN_ERROR2_H
31 #define NDN_ERROR2_H
32 
33 #include "ns3/ndn-common.h"
34 #include <boost/exception/all.hpp>
35 
36 NDN_NAMESPACE_BEGIN
37 
42 namespace error
43 {
44 
45 struct Error : public virtual boost::exception, public virtual std::exception {};
46 struct Uri : public virtual boost::exception, public virtual std::exception {};
47 struct StringTransform : public virtual boost::exception, public virtual std::exception {};
48 struct Name : public virtual boost::exception, public virtual std::exception {};
49 namespace name {
50 struct Component : public virtual boost::exception, public virtual std::exception {};
51 }
52 struct Exclude : public virtual boost::exception, public virtual std::exception {};
53 struct KeyLocator : public virtual boost::exception, public virtual std::exception {};
54 namespace wire {
55 struct Ccnb : public virtual boost::exception, public virtual std::exception {};
56 }
57 struct Keychain : public virtual boost::exception, public virtual std::exception {};
58 
59 // Diagnostic information fields
60 
75 typedef boost::error_info<struct tag_msg, std::string> msg;
76 
82 inline const std::string &
83 get_msg (boost::exception &e)
84 {
85  const std::string *error = boost::get_error_info<msg> (e);
86  if (error == 0)
87  BOOST_THROW_EXCEPTION (Error ());
88  return *error;
89 }
90 
105 typedef boost::error_info<struct tag_pos, int> pos;
106 
112 inline int
113 get_pos (boost::exception &e)
114 {
115  const int *position = boost::get_error_info<pos> (e);
116  if (position == 0)
117  BOOST_THROW_EXCEPTION (Error ());
118  return *position;
119 }
120 
121 } // error
122 
123 NDN_NAMESPACE_END
124 
125 #endif // NDN_ERROR2_H
int get_pos(boost::exception &e)
Helper method to get position of the error from the exception.
Definition: error.h:113
An error with Exclude.
Definition: error.h:52
An error with name::Component.
Definition: error.h:50
boost::error_info< struct tag_msg, std::string > msg
Free-formatted text message explaining the error.
Definition: error.h:75
An error with Name.
Definition: error.h:48
boost::error_info< struct tag_pos, int > pos
Report of the position of the error (error-specific meaning)
Definition: error.h:105
An error with wire::Ccnb encoding.
Definition: error.h:55
An error with URI processing.
Definition: error.h:46
Some error with error reporting engine.
Definition: error.h:45
const std::string & get_msg(boost::exception &e)
Helper method to get error message from the exception.
Definition: error.h:83
An error with security::Keychain.
Definition: error.h:57
An error with KeyLocator.
Definition: error.h:53