bes  Updated for version 3.17.0
BESError.h
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 #include "BESObj.h"
39 
40 #define BES_INTERNAL_ERROR 1
41 
42 // BES_INTERNAL_FATAL_ERROR will cause the bes listener to exit()
43 // while the others (BES_INTERNAL_ERROR, ...) won't.
44 #define BES_INTERNAL_FATAL_ERROR 2
45 
46 #define BES_SYNTAX_USER_ERROR 3
47 #define BES_FORBIDDEN_ERROR 4
48 #define BES_NOT_FOUND_ERROR 5
49 
50 // I added this for the timeout feature. jhrg 12/28/15
51 #define BES_TIMEOUT_ERROR 6
52 
56 class BESError: public BESObj {
57 protected:
58  std::string _msg;
59  unsigned int _type;
60  std::string _file;
61  unsigned int _line;
62 
63  BESError(): _msg("UNDEFINED"), _type(0), _file(""), _line(0) { }
64 
65 public:
77  BESError(const std::string &msg, unsigned int type, const std::string &file, unsigned int line) :
78  _msg(msg), _type(type), _file(file), _line(line)
79  {
80  }
81  virtual ~BESError()
82  {
83  }
84 
89  virtual void set_message(const std::string &msg)
90  {
91  _msg = msg;
92  }
97  virtual std::string get_message()
98  {
99  return _msg;
100  }
105  virtual std::string get_file()
106  {
107  return _file;
108  }
113  virtual int get_line()
114  {
115  return _line;
116  }
117 
127  virtual void set_error_type(int type)
128  {
129  _type = type;
130  }
131 
138  virtual int get_error_type()
139  {
140  return _type;
141  }
142 
147  virtual void dump(std::ostream &strm) const;
148 };
149 
150 #endif // BESError_h_
virtual void set_error_type(int type)
Set the return code for this particular error class.
Definition: BESError.h:127
virtual std::string get_message()
get the error message for this exception
Definition: BESError.h:97
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
Definition: BESError.cc:44
virtual int get_error_type()
Return the return code for this error class.
Definition: BESError.h:138
Base object for bes objects.
Definition: BESObj.h:52
BESError(const std::string &msg, unsigned int type, const std::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:77
Abstract exception class for the BES with basic string message.
Definition: BESError.h:56
virtual void set_message(const std::string &msg)
set the error message for this exception
Definition: BESError.h:89
virtual std::string get_file()
get the file name where the exception was thrown
Definition: BESError.h:105
virtual int get_line()
get the line number where the exception was thrown
Definition: BESError.h:113