File: error.h

package info (click to toggle)
openalpp-cvs 20041206-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,796 kB
  • ctags: 549
  • sloc: cpp: 3,891; makefile: 154; ansic: 56; sh: 5
file content (160 lines) | stat: -rwxr-xr-x 4,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
 * OpenAL++ - an object oriented toolkit for spatial sound
 * Copyright (C) 2002 VRlab, Ume University
 *
 * OpenAL++ was created using the libraries:
 *                 OpenAL (http://www.openal.org), 
 *              PortAudio (http://www.portaudio.com/), and
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 */

#ifndef ERROR_H_INCLUDED_C416C52E
#define ERROR_H_INCLUDED_C416C52E

#include <iostream>
#include <string>
#include <stdexcept>
#include "openalpp/export.h"
namespace openalpp {

/**
 * Error class for throwing.
 * The descendants of this class are different error types, and the exact
 * error can be displayed by using "cout << error;" where error is an instance
 * of Error (or one of its descendants)
 */
 class Error : public std::runtime_error {
 public:
  /**
   * Constructor.
   * Will use a default error message.
   */
  Error() : runtime_error("No error description") {}

  /**
   * Constructor.
   * @param description is error message to use.
   */
  Error(const char *description) : runtime_error(description)  {}

  /**
   * Copy constructor.
   */
  Error(const Error &error) : runtime_error(error.what())  {}

  /**
   * Function used for printing.
   * @param stream is stream to print to
   * @return the stream with the error message appended.
   */
  std::ostream &put(std::ostream &stream) const;

 protected:
  /**
   * A description of the error
   */
};

/**
 * Fatal error.
 * Caused by error in implementation, corrupted memory etc.
 */
class  FatalError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  FatalError(const char *description) : Error(description) {}
};

/**
 * File error.
 * Caused by wrong file permissions, missing files etc.
 */
class   FileError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  FileError(const char *description) : Error(description) {}
};

/**
 * Memory error.
 * Caused by insufficient memory etc.
 */
class   MemoryError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  MemoryError(const char *description) : Error(description) {}
};

/**
 * Name error.
 * Caused by invalid (OpenAL) names.
 */
class   NameError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  NameError(const char *description) : Error(description) {}
};

/**
 * Value error.
 * Caused by values out of range etc.
 */
class   ValueError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  ValueError(const char *description) : Error(description) {}
};

/**
 * Init error.
 * Caused by trying to do actions without proper initialization.
 */
class   InitError : public Error {
 public:
  /**
   * Constructor.
   * @param description is error message to use.
   */
  InitError(const char *description) : Error(description) {}
};

/**
 * Out stream operator.
 * Used to print error messages to a stream (i.e. "cerr << error;").
 * @param stream is the stream to print to.
 * @param error is the error to print.
 * @return the stream.
 */
 OPENALPP_API std::ostream &operator<<(std::ostream &stream,const Error &error);

}

#endif /* ERROR_H_INCLUDED_C416C52E */