LSSTApplications  20.0.0
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
lsst::pex::policy::SyntaxError::SyntaxError
SyntaxError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
Definition: parserexceptions.h:135
std::string
STL class.
lsst::pex::policy::SyntaxError::SyntaxError
SyntaxError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
Definition: parserexceptions.h:129
lsst::pex::policy::UnsupportedSyntax::UnsupportedSyntax
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
Definition: parserexceptions.h:197
lsst::pex::policy::EOFError
an exception indicated that the stream being parsed ended prematurely.
Definition: parserexceptions.h:85
lsst::pex::policy::FormatSyntaxError::FormatSyntaxError
FormatSyntaxError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
Definition: parserexceptions.h:160
lsst::pex::policy::FormatSyntaxError::getType
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.
std::ends
T ends(T... args)
lsst::pex::policy::UnsupportedSyntax::getType
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.
lsst::pex::policy::EOFError::EOFError
EOFError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
Definition: parserexceptions.h:90
lsst::pex::policy::ParserError::ParserError
ParserError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
Definition: parserexceptions.h:59
lsst::pex::policy::FormatSyntaxError
an exception thrown because a syntax error specific to the format being parsed was encountered.
Definition: parserexceptions.h:155
lsst::pex::policy::ParserError::makeLocatedMessage
static std::string makeLocatedMessage(const std::string &msg, int lineno)
Definition: parserexceptions.h:72
pex
Definition: __init__.py:1
lsst::pex::policy::UnsupportedSyntax::UnsupportedSyntax
UnsupportedSyntax(POL_EARGS_TYPED)
Create an exception the exception with a default message.
Definition: parserexceptions.h:191
lsst::pex::policy::ParserError::clone
virtual lsst::pex::exceptions::Exception * clone() const
Return a copy of the exception as an Exception pointer.
lsst::pex::policy::SyntaxError::SyntaxError
SyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: parserexceptions.h:144
lsst::pex::policy::EOFError::EOFError
EOFError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
Definition: parserexceptions.h:96
lsst::pex::policy::FormatSyntaxError::FormatSyntaxError
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg)
Create an exception the exception with a given message.
Definition: parserexceptions.h:166
lsst::pex::policy::EOFError::EOFError
EOFError(POL_EARGS_TYPED, int lineno)
Create an exception the exception with a default message.
Definition: parserexceptions.h:104
lsst::pex::policy::ParserError::ParserError
ParserError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: parserexceptions.h:69
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
std::ostringstream
STL class.
lsst::pex::policy::ParserError
an parent exception for errors that occur during the parsing of policy files.
Definition: parserexceptions.h:46
POL_EARGS_TYPED
#define POL_EARGS_TYPED
Definition: exceptions.h:38
lsst::pex::policy::FormatSyntaxError::FormatSyntaxError
FormatSyntaxError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: parserexceptions.h:175
lsst::pex::policy::EOFError::EOFError
EOFError(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: parserexceptions.h:114
exceptions.h
definition of Policy-specific exceptions classes
lsst::pex::policy::SyntaxError::getType
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.
lsst::pex::policy::SyntaxError
an exception thrown because a general syntax error was encountered.
Definition: parserexceptions.h:124
lsst::pex::policy::UnsupportedSyntax
an exception thrown because syntax was encountered that is legal for the format being parsed but whic...
Definition: parserexceptions.h:186
POL_EARGS_UNTYPED
#define POL_EARGS_UNTYPED
Definition: exceptions.h:39
std::ostringstream::str
T str(T... args)
lsst::pex::exceptions::Exception::Exception
Exception(char const *file, int line, char const *func, std::string const &message)
Standard constructor, intended for C++ use via the LSST_EXCEPT() macro.
Definition: Exception.cc:42
lsst::pex::policy::ParserError::ParserError
ParserError(POL_EARGS_TYPED)
Create an exception the exception with a default message.
Definition: parserexceptions.h:51
lsst::pex::policy::EOFError::getType
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.
lsst::pex::policy::UnsupportedSyntax::UnsupportedSyntax
UnsupportedSyntax(POL_EARGS_TYPED, const std::string &msg, int lineno)
Create an exception the exception with a given message.
Definition: parserexceptions.h:206
lsst::pex::exceptions::RuntimeError
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
lsst::pex::policy::ParserError::getType
virtual char const * getType() const
Return the fully-specified C++ type of a pointer to the exception.