LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
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 
47 public:
52  : lsst::pex::exceptions::RuntimeError(POL_EARGS_UNTYPED,
53  "Unspecified parsing error encountered") {}
54 
60  : lsst::pex::exceptions::RuntimeError(POL_EARGS_UNTYPED, msg) {}
61 
69  ParserError(POL_EARGS_TYPED, const std::string& msg, int lineno)
70  : lsst::pex::exceptions::RuntimeError(POL_EARGS_UNTYPED, makeLocatedMessage(msg, lineno)) {}
71 
72  static std::string makeLocatedMessage(const std::string& msg, int lineno) {
74  out << "Policy Parsing Error:" << lineno << ": " << msg << std::ends;
75  return out.str();
76  }
77 
78  virtual char const* getType() const throw();
79  virtual lsst::pex::exceptions::Exception* clone() const;
80 };
81 
85 class EOFError : public ParserError {
86 public:
90  EOFError(POL_EARGS_TYPED) : ParserError(POL_EARGS_UNTYPED, "Unexpected end of Policy data stream") {}
91 
97 
105  : ParserError(POL_EARGS_UNTYPED, "Unexpected end of Policy data stream", lineno) {}
106 
114  EOFError(POL_EARGS_TYPED, const std::string& msg, int lineno)
115  : ParserError(POL_EARGS_UNTYPED, msg, lineno) {}
116 
117  virtual char const* getType() const throw();
118  virtual lsst::pex::exceptions::Exception* clone() const;
119 };
120 
124 class SyntaxError : public ParserError {
125 public:
130 
136 
144  SyntaxError(POL_EARGS_TYPED, const std::string& msg, int lineno)
145  : ParserError(POL_EARGS_UNTYPED, msg, lineno) {}
146 
147  virtual char const* getType() const throw();
148  virtual lsst::pex::exceptions::Exception* clone() const;
149 };
150 
156 public:
161 
167 
176  : SyntaxError(POL_EARGS_UNTYPED, msg, lineno) {}
177 
178  virtual char const* getType() const throw();
179  virtual lsst::pex::exceptions::Exception* clone() const;
180 };
181 
187 public:
192 
198 
207  : SyntaxError(POL_EARGS_UNTYPED, msg, lineno) {}
208 
209  virtual char const* getType() const throw();
210  virtual lsst::pex::exceptions::Exception* clone() const;
211 };
212 
213 } // namespace policy
214 } // namespace pex
215 } // namespace lsst
216 
217 #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.
Provides consistent interface for LSST exceptions.
Definition: Exception.h:107
STL class.
A base class for image defects.
#define POL_EARGS_TYPED
Definition: exceptions.h:38
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.
T str(T... args)
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.
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.
EOFError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: __init__.py:1
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
T ends(T... args)
an exception thrown because a general syntax error was encountered.
#define POL_EARGS_UNTYPED
Definition: exceptions.h:39
virtual lsst::pex::exceptions::Exception * clone() const
Return a copy of the exception as an Exception pointer.
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.
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
ParserError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
definition of Policy-specific exceptions classes