jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
exception.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2012 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_COMMON_JSONCONFIG_EXCEPTION_HPP_
18 #define JUBATUS_CORE_COMMON_JSONCONFIG_EXCEPTION_HPP_
19 
20 #include <string>
21 #include <stdexcept>
22 #include <typeinfo>
23 #include <vector>
24 
25 #include "jubatus/util/text/json.h"
26 #include "jubatus/util/lang/shared_ptr.h"
27 
28 #include "../exception.hpp"
29 
30 namespace jubatus {
31 namespace core {
32 namespace common {
33 namespace jsonconfig {
34 
35 class config_error : public common::exception::jubaexception<config_error> {
36  public:
37  config_error(const std::string& path, const std::string& message);
38 
39  ~config_error() throw ();
40 
41  const std::string& path() const {
42  return path_;
43  }
44 
45  const char* what() const throw () {
46  return message_.c_str();
47  }
48 
49  private:
50  const std::string path_;
51  const std::string message_;
52 };
53 
54 class type_error : public config_error {
55  public:
56  type_error(
57  const std::string& path,
58  jubatus::util::text::json::json::json_type_t expect,
59  jubatus::util::text::json::json::json_type_t actual);
60 
61  ~type_error() throw ();
62 
63  jubatus::util::text::json::json::json_type_t expect() const {
64  return expect_;
65  }
66 
67  jubatus::util::text::json::json::json_type_t actual() const {
68  return actual_;
69  }
70 
71  private:
72  const jubatus::util::text::json::json::json_type_t expect_;
73  const jubatus::util::text::json::json::json_type_t actual_;
74 };
75 
76 class out_of_range : public config_error {
77  public:
78  out_of_range(const std::string& path, size_t size, size_t index);
79 
80  ~out_of_range() throw ();
81 
82  size_t size() const {
83  return size_;
84  }
85 
86  size_t position() const {
87  return index_;
88  }
89 
90  private:
91  size_t size_;
92  size_t index_;
93 };
94 
95 class not_found : public config_error {
96  public:
97  not_found(const std::string& path, const std::string& key);
98 
99  ~not_found() throw ();
100 
101  const std::string& key() const {
102  return key_;
103  }
104 
105  private:
106  std::string key_;
107 };
108 
109 class redundant_key : public config_error {
110  public:
111  redundant_key(const std::string& path, const std::string& key);
112 
113  ~redundant_key() throw();
114 
115  const std::string& key() const {
116  return key_;
117  }
118 
119  private:
120  std::string key_;
121 };
122 
123 // cast_check_error DOES NOT INHERIT Config_error
125  : public common::exception::jubaexception<cast_check_error> {
126  public:
128  const std::vector<jubatus::util::lang::shared_ptr<config_error> >&
129  errors);
130 
131  ~cast_check_error() throw ();
132 
133  size_t size() const {
134  return errors_.size();
135  }
136 
137  const std::vector<jubatus::util::lang::shared_ptr<config_error> >& errors()
138  const {
139  return errors_;
140  }
141 
142  private:
143  std::vector<jubatus::util::lang::shared_ptr<config_error> > errors_;
144 };
145 
146 } // namespace jsonconfig
147 } // namespace common
148 } // namespace core
149 } // namespace jubatus
150 #endif // JUBATUS_CORE_COMMON_JSONCONFIG_EXCEPTION_HPP_
out_of_range(const std::string &path, size_t size, size_t index)
Definition: exception.cpp:96
jubatus::util::text::json::json::json_type_t actual() const
Definition: exception.hpp:67
const jubatus::util::text::json::json::json_type_t expect_
Definition: exception.hpp:72
const jubatus::util::text::json::json::json_type_t actual_
Definition: exception.hpp:73
redundant_key(const std::string &path, const std::string &key)
Definition: exception.cpp:113
jubatus::util::text::json::json::json_type_t expect() const
Definition: exception.hpp:63
type_error(const std::string &path, jubatus::util::text::json::json::json_type_t expect, jubatus::util::text::json::json::json_type_t actual)
Definition: exception.cpp:84
not_found(const std::string &path, const std::string &key)
Definition: exception.cpp:105
std::vector< jubatus::util::lang::shared_ptr< config_error > > errors_
Definition: exception.hpp:143
cast_check_error(const std::vector< jubatus::util::lang::shared_ptr< config_error > > &errors)
Definition: exception.cpp:121
config_error(const std::string &path, const std::string &message)
Definition: exception.cpp:30
const std::vector< jubatus::util::lang::shared_ptr< config_error > > & errors() const
Definition: exception.hpp:137
const std::string & key() const
Definition: exception.hpp:101