LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 
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)
Create an exception the exception with a given message.
EOFError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
SyntaxError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
ParserError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
an exception indicated that the stream being parsed ended prematurely.
SyntaxError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
ParserError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
EOFError(POL_EARGS_TYPED, int lineno)
Create an exception the exception with a default message.
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
virtual char const * getType() const
virtual lsst::pex::exceptions::Exception * clone() const
an exception thrown because a syntax error specific to the format being parsed was encountered...
an parent exception for errors that occur during the parsing of policy files.
SyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
#define POL_EARGS_UNTYPED
Definition: exceptions.h:38
static std::string makeLocatedMessage(const std::string &msg, int lineno)
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
EOFError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
#define POL_EARGS_TYPED
Definition: exceptions.h:37
definition of Policy-specific exceptions classes
an exception thrown because a general syntax error was encountered.
FormatSyntaxError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
an exception thrown because syntax was encountered that is legal for the format being parsed but whic...
UnsupportedSyntax(POL_EARGS_TYPED)
Create an exception the exception with a default message.
ParserError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.