bes Updated for version 3.20.10
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// But, see the new option BES.ExitOnInternalError, which causes the
45// BES to exit on an InternalError.
46#define BES_INTERNAL_FATAL_ERROR 2
47
48#define BES_SYNTAX_USER_ERROR 3
49#define BES_FORBIDDEN_ERROR 4
50#define BES_NOT_FOUND_ERROR 5
51
52// I added this for the timeout feature. jhrg 12/28/15
53#define BES_TIMEOUT_ERROR 6
54
58class BESError: public BESObj {
59protected:
60 std::string _msg;
61 unsigned int _type;
62 std::string _file;
63 unsigned int _line;
64
65 BESError(): _msg("UNDEFINED"), _type(0), _file(""), _line(0) { }
66
67public:
79 BESError(const std::string &msg, unsigned int type, const std::string &file, unsigned int line) :
80 _msg(msg), _type(type), _file(file), _line(line)
81 {
82 }
83 virtual ~BESError()
84 {
85 }
86
91 virtual void set_message(const std::string &msg)
92 {
93 _msg = msg;
94 }
99 virtual std::string get_message()
100 {
101 return _msg;
102 }
107 virtual std::string get_file()
108 {
109 return _file;
110 }
115 virtual int get_line()
116 {
117 return _line;
118 }
119
120 // Return the message, file and line
121 virtual std::string get_verbose_message();
122
132 virtual void set_bes_error_type(int type)
133 {
134 _type = type;
135 }
136
143 virtual int get_bes_error_type()
144 {
145 return _type;
146 }
147
152 virtual void dump(std::ostream &strm) const;
153};
154
155#endif // BESError_h_
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58
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:79
virtual int get_bes_error_type()
Return the return code for this error class.
Definition: BESError.h:143
virtual void set_bes_error_type(int type)
Set the return code for this particular error class.
Definition: BESError.h:132
virtual int get_line()
get the line number where the exception was thrown
Definition: BESError.h:115
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
Definition: BESError.cc:59
virtual std::string get_file()
get the file name where the exception was thrown
Definition: BESError.h:107
virtual std::string get_message()
get the error message for this exception
Definition: BESError.h:99
virtual void set_message(const std::string &msg)
set the error message for this exception
Definition: BESError.h:91
top level BES object to house generic methods
Definition: BESObj.h:50