LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
parserexceptions.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
32 #ifndef LSST_PEX_POLICY_PARSER_EXCEPTIONS_H
33 #define LSST_PEX_POLICY_PARSER_EXCEPTIONS_H
34 
36 #include <sstream>
37 
38 namespace lsst {
39 namespace pex {
40 namespace policy {
41 
46 class ParserError : public lsst::pex::exceptions::RuntimeError {
47 public:
48 
53  : lsst::pex::exceptions::RuntimeError(
54  POL_EARGS_UNTYPED, "Unspecified parsing error encountered")
55  { }
56 
61  ParserError(POL_EARGS_TYPED, const std::string& msg)
62  : lsst::pex::exceptions::RuntimeError(POL_EARGS_UNTYPED, msg)
63  { }
64 
72  ParserError(POL_EARGS_TYPED, const std::string& msg, int lineno)
73  : lsst::pex::exceptions::RuntimeError(
75  { }
76 
77  static std::string makeLocatedMessage(const std::string& msg, int lineno) {
78  std::ostringstream out;
79  out << "Policy Parsing Error:" << lineno << ": " << msg << std::ends;
80  return out.str();
81  }
82 
83  virtual char const *getType() const throw();
84  virtual lsst::pex::exceptions::Exception *clone() const;
85 };
86 
90 class EOFError : public ParserError {
91 public:
92 
97  : ParserError(POL_EARGS_UNTYPED,
98  "Unexpected end of Policy data stream")
99  { }
100 
105  EOFError(POL_EARGS_TYPED, const std::string& msg)
106  : ParserError(POL_EARGS_UNTYPED, msg) { }
107 
114  EOFError(POL_EARGS_TYPED, int lineno)
115  : ParserError(POL_EARGS_UNTYPED,
116  "Unexpected end of Policy data stream", lineno)
117  { }
118 
126  EOFError(POL_EARGS_TYPED, const std::string& msg, int lineno)
127  : ParserError(POL_EARGS_UNTYPED, msg, lineno) { }
128 
129  virtual char const *getType() const throw();
130  virtual lsst::pex::exceptions::Exception *clone() const;
131 };
132 
136 class SyntaxError : public ParserError {
137 public:
138 
143  : ParserError(POL_EARGS_UNTYPED, "Unknonwn syntax error") { }
144 
149  SyntaxError(POL_EARGS_TYPED, const std::string& msg)
150  : ParserError(POL_EARGS_UNTYPED, msg) { }
151 
159  SyntaxError(POL_EARGS_TYPED, const std::string& msg, int lineno)
160  : ParserError(POL_EARGS_UNTYPED, msg, lineno) { }
161 
162  virtual char const *getType() const throw();
163  virtual lsst::pex::exceptions::Exception *clone() const;
164 };
165 
171 public:
172 
177  : SyntaxError(POL_EARGS_UNTYPED, "Unknonwn syntax error") { }
178 
183  FormatSyntaxError(POL_EARGS_TYPED, const std::string& msg)
184  : SyntaxError(POL_EARGS_UNTYPED, msg) { }
185 
193  FormatSyntaxError(POL_EARGS_TYPED, const std::string& msg, int lineno)
194  : SyntaxError(POL_EARGS_UNTYPED, msg, lineno) { }
195 
196  virtual char const *getType() const throw();
197  virtual lsst::pex::exceptions::Exception *clone() const;
198 };
199 
204 class UnsupportedSyntax : public SyntaxError {
205 public:
206 
211  : SyntaxError(POL_EARGS_UNTYPED, "Unsupported syntax error") { }
212 
217  UnsupportedSyntax(POL_EARGS_TYPED, const std::string& msg)
218  : SyntaxError(POL_EARGS_UNTYPED, msg) { }
219 
227  UnsupportedSyntax(POL_EARGS_TYPED, const std::string& msg, int lineno)
228  : SyntaxError(POL_EARGS_UNTYPED, msg, lineno) { }
229 
230  virtual char const *getType() const throw();
231  virtual lsst::pex::exceptions::Exception *clone() const;
232 };
233 
234 
235 
236 
237 }}} // end namespace lsst::pex::policy
238 
239 
240 #endif // LSST_PEX_POLICY_PARSER_EXCEPTIONS_H
EOFError(POL_EARGS_TYPED, const std::string &msg)
ParserError(POL_EARGS_TYPED, const std::string &msg, int lineno)
definition of Policy-specific exceptions classes
virtual lsst::pex::exceptions::Exception * clone() const
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg)
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
SyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg)
#define POL_EARGS_UNTYPED
Definition: exceptions.h:38
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg, int lineno)
ParserError(POL_EARGS_TYPED, const std::string &msg)
virtual char const * getType() const
SyntaxError(POL_EARGS_TYPED, const std::string &msg)
#define POL_EARGS_TYPED
Definition: exceptions.h:37
EOFError(POL_EARGS_TYPED, const std::string &msg, int lineno)
EOFError(POL_EARGS_TYPED, int lineno)
static std::string makeLocatedMessage(const std::string &msg, int lineno)