casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATMException.h
Go to the documentation of this file.
1 #ifndef _ATM_EXCEPTIONS_H
2 #define _ATM_EXCEPTIONS_H
3 
4 /****************************************************************************
5  * ALMA - Atacama Large Millimiter Array
6  * (c) Instituto de Estructura de la Materia, 2009
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * "@(#) $Id: ATMException.h Exp $"
23  *
24  * who when what
25  * -------- -------- ----------------------------------------------
26  * jroche 09/09/09 created
27  */
28 
29 #ifndef __cplusplus
30 #error "This is a C++ include file and cannot be used from plain C"
31 #endif
32 
33 #include "ATMCommon.h"
34 #include <exception>
35 #include <string>
36 
37 using std::string;
38 
40 
118 class AtmException : public std::exception
119 {
120 public:
121  // --------------------------------------------------
123  // --------------------------------------------------
129  AtmException(const char* msg) throw();
141  AtmException(const char* file, const char* routine, int line, const char* msg) throw();
145  virtual ~AtmException() throw()
146  {
147  }
149 
150  // --------------------------------------------------
152  // --------------------------------------------------
158  virtual const char* file() const throw() { return file_m.c_str(); }
163  virtual const char* routine() const throw() { return routine_m.c_str(); }
169  virtual int line() const throw() { return line_m; }
174  virtual const char* message() const throw() { return msg_m.c_str(); }
179  virtual const char* what() const throw() { return what_m.c_str(); }
181 
182 private:
183  // --------------------------------------------------
185  // --------------------------------------------------
195  string formatMsg(const char* file, const char* routine, int line, const char* msg);
197 
198 private:
199  string file_m;
200  string routine_m;
201  int line_m;
202  string msg_m;
203  string what_m;
204 }; // class AtmException
205 
207 
224 #define ATM_EXCEPTION_ARGS(msg) __FILE__, __PRETTY_FUNCTION__, __LINE__, msg
225 
226 #endif
#define ATM_NAMESPACE_END
Definition: ATMCommon.h:38
virtual const char * file() const
Returns the file name where the current error raised.
Definition: ATMException.h:158
string file_m
The file where the exception raised.
Definition: ATMException.h:199
string routine_m
The routine where the exception raised.
Definition: ATMException.h:200
AtmException(const char *msg)
Constructor.
virtual const char * what() const
Returns a string describing the general cause of the current error.
Definition: ATMException.h:179
virtual const char * message() const
Returns the message where the current error raised.
Definition: ATMException.h:174
#define ATM_NAMESPACE_BEGIN
Definition: ATMCommon.h:37
string msg_m
The message where the exception raised.
Definition: ATMException.h:202
string formatMsg(const char *file, const char *routine, int line, const char *msg)
Output a message that conform to a given trace pattern.
virtual ~AtmException()
Destructor.
Definition: ATMException.h:145
virtual int line() const
Returns the line number where the current error raised.
Definition: ATMException.h:169
string what_m
The error message to be displayed.
Definition: ATMException.h:203
Manage exceptions that raises in ATM.
Definition: ATMException.h:118
int line_m
The line where the exception raised.
Definition: ATMException.h:201
virtual const char * routine() const
Returns the routine name where the current error raised.
Definition: ATMException.h:163
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100