libdap Updated for version 3.18.1
Error.h
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5// Access Protocol.
6
7// Copyright (c) 2002,2003 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library 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 GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26// (c) COPYRIGHT URI/MIT 1999,2000
27// Please read the full copyright statement in the file COPYRIGHT_URI.
28//
29// Authors:
30// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31
32// Interface for the Error class
33//
34// jhrg 4/23/96
35
36#ifndef _error_h
37#define _error_h
38
39#include <cstdio> // For FILE *
40#include <iostream>
41#include <string>
42
43using std::cout;
44using std::string;
45using std::ostream;
46
47namespace libdap
48{
49
55typedef int ErrorCode; //using standard errno+netCDF error codes from server
56
59#define undefined_error 1000
60#define unknown_error 1001
61#define internal_error 1002
62#define no_such_file 1003
63#define no_such_variable 1004
64#define malformed_expr 1005
65#define no_authorization 1006
66#define cannot_read_file 1007
67#define not_implemented 1008
68#define dummy_message 1009
70
90class Error
91{
92protected:
93 ErrorCode _error_code;
94 string _error_message;
95
96public:
97 Error(ErrorCode ec, string msg);
98 Error(string msg);
99 Error();
100
101 Error(const Error &copy_from);
102
103 virtual ~Error();
104
105 Error &operator=(const Error &rhs);
106
107 bool OK() const;
108 bool parse(FILE *fp);
109 void print(FILE *out) const;
110 void print(ostream &out) const;
112 string get_error_message() const;
113 void set_error_code(ErrorCode ec = undefined_error);
114 void set_error_message(string msg = "");
115};
116
117} // namespace libdap
118
119#endif // _error_h
A class for error processing.
Definition: Error.h:91
void set_error_code(ErrorCode ec=undefined_error)
Definition: Error.cc:260
void print(FILE *out) const
Definition: Error.cc:198
ErrorCode get_error_code() const
Definition: Error.cc:247
string get_error_message() const
Definition: Error.cc:276
bool parse(FILE *fp)
Parse an Error object.
Definition: Error.cc:156
bool OK() const
Is the Error object valid?
Definition: Error.cc:133
void set_error_message(string msg="")
Definition: Error.cc:285
int ErrorCode
An enumerated type for common errors.
Definition: Error.h:55