OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESError.h
Go to the documentation of this file.
1 // BESError.h
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #ifndef BESError_h_
34 #define BESError_h_ 1
35 
36 #include <string>
37 
38 using std::string;
39 
40 #include "BESObj.h"
41 
42 #define BES_INTERNAL_ERROR 1
43 #define BES_INTERNAL_FATAL_ERROR 2
44 #define BES_SYNTAX_USER_ERROR 3
45 #define BES_FORBIDDEN_ERROR 4
46 #define BES_NOT_FOUND_ERROR 5
47 
51 class BESError: public BESObj {
52 protected:
53  string _msg;
54  unsigned int _type;
55  string _file;
56  unsigned int _line;
57 
59  {
60  _msg = "UNDEFINED";
61  }
62 public:
74  BESError(const string &msg, unsigned int type, const string &file, unsigned int line) :
75  _msg(msg), _type(type), _file(file), _line(line)
76  {
77  }
78  virtual ~BESError()
79  {
80  }
81 
86  virtual void set_message(const string &msg)
87  {
88  _msg = msg;
89  }
94  virtual string get_message()
95  {
96  return _msg;
97  }
102  virtual string get_file()
103  {
104  return _file;
105  }
110  virtual int get_line()
111  {
112  return _line;
113  }
114 
124  virtual void set_error_type(int type)
125  {
126  _type = type;
127  }
128 
135  virtual int get_error_type()
136  {
137  return _type;
138  }
139 
144  virtual void dump(ostream &strm) const;
145 };
146 
147 #endif // BESError_h_
virtual ~BESError()
Definition: BESError.h:78
virtual void dump(ostream &strm) const
Displays debug information about this object.
Definition: BESError.cc:44
virtual void set_error_type(int type)
Set the return code for this particular error class.
Definition: BESError.h:124
virtual int get_error_type()
Return the return code for this error class.
Definition: BESError.h:135
Base object for bes objects.
Definition: BESObj.h:52
virtual string get_file()
get the file name where the exception was thrown
Definition: BESError.h:102
virtual string get_message()
get the error message for this exception
Definition: BESError.h:94
string _msg
Definition: BESError.h:53
Abstract exception class for the BES with basic string message.
Definition: BESError.h:51
BESError(const string &msg, unsigned int type, const string &file, unsigned int line)
constructor that takes message, type of error, source file the error originated and the line number i...
Definition: BESError.h:74
unsigned int _line
Definition: BESError.h:56
virtual void set_message(const string &msg)
set the error message for this exception
Definition: BESError.h:86
BESError()
Definition: BESError.h:58
string _file
Definition: BESError.h:55
unsigned int _type
Definition: BESError.h:54
virtual int get_line()
get the line number where the exception was thrown
Definition: BESError.h:110