Awali
Another Weighted Automata library
exceptions.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2021 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_JSON_EXCEPTIONS_HH
18 #define AWALI_JSON_EXCEPTIONS_HH
19 
21 
22 namespace awali {
23 namespace json {
24 
26 class exception : public std::exception {
27 public:
28  std::string message;
29  std::string caller;
30  std::string what_msg;
31 
32  virtual std::string make_message();
33 
34  exception(std::string message, std::string caller = "") :
35  message(std::move(message)),
36  caller(std::move(caller))
37  { what_msg = build_message(); }
38 
39 
40  virtual const char* what() const noexcept override
41  {return what_msg.c_str();}
42 };
43 
45 protected:
49 
50 public:
54 
60 
62 
63  parse_exception (std::string caller, std::string message, path_t path,
64  parser_t::, node_t* tree);
65 
66 };
67 
68 
70 public:
74 
75 };
76 
77 
79 
80 };
81 
82 
84 
85 };
86 
87 
88 }// end of namespace awali::json
89 }// end of namespace awali
90 
91 #endif
Definition: exceptions.hh:69
node_t const * localisation
Where the exception occured.
Definition: exceptions.hh:73
Exception used when trying to coerce a node to a given type.
Definition: exceptions.hh:83
The main exception for json manipulation.
Definition: exceptions.hh:26
virtual std::string make_message()
virtual const char * what() const noexcept override
Definition: exceptions.hh:40
std::string caller
Definition: exceptions.hh:29
exception(std::string message, std::string caller="")
Definition: exceptions.hh:34
std::string what_msg
Definition: exceptions.hh:30
std::string message
Definition: exceptions.hh:28
Definition: exceptions.hh:78
Definition: node.hh:191
Definition: exceptions.hh:44
parse_exception(std::string caller, std::string message, path_t path, parser_t::, node_t *tree)
node_t * partial_tree()
Give the partial_tree parsed before the the exception was throwned.
parser_t::position_t start
Definition: exceptions.hh:52
~parse_exception()
Definition: exceptions.hh:61
node_t * _partial_tree
Partial tree managed to be parsed before the exception was thrown.
Definition: exceptions.hh:48
parser_t::position_t end
Definition: exceptions.hh:53
path_t path_on_throw
Definition: exceptions.hh:51
Definition: parser.hh:28
std::ostream & json(automaton_t aut, std::ostream &out)
std::vector< uint_or_string_t > path_t
Definition: node.hh:82
Main namespace of Awali.
Definition: ato.hh:22
Definition: parser.hh:30