PrevUpHomeNext

Error reporting and handling

Basic exception class

In order to detect and report any errors that occured during the calls to OpenAL functions, OALplus consistently checks the result of the alGetError, alcGetError and alutGetError functions and if an error is indicated it throws an instance of an appropriate exception class. The exceptions (described below) contain a lot of useful information about the error and are highly configurable. See the chapter Error-related configuration options for more information.

#include <oalplus/error/basic.hpp>

Error is an exception class for general OpenAL errors. Instances of this exception class are thrown whenever an error is detected during the execution of OpenAL API calls in the OALplus code. This class is derived from the standard runtime_error exception and thus the basic error message can be obtained by calling its what() member function. There are several other classes derived for more specific error types.

class Error
 : public std::runtime_error
{
public:
	static const char* Message(ALenum error_code); 1

	Error(const char* message); 2
	~Error(void) throw() { }

	ALenum Code(void) const; 3

	const char* SourceFile(void) const; 4
	const char* SourceFunc(void) const; 5
	unsigned SourceLine(void) const; 6

	const char* ALLib(void) const; 7
	const char* ALFunc(void) const; 8

	ALenum EnumParam(void) const; 9
	const char* EnumParamName(void) const; 10

	virtual ALenum ObjectType(void) const; 11
	virtual ALint ObjectName(void) const; 12
	virtual const std::string& ObjectDesc(void) const; 13
};

1

Returns a message for the specified error_code.

2

Constructs a new instance of Error with the specified error message.

3

Return the AL error code associated with this error.

4

Returns the name of the OALplus source file where the error occured. The result of this function is also influenced by the __OALPLUS_ERROR_NO_FILE preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns a nullptr.

5

Returns the name of the OALplus function where the error occured. The result of this function is also influenced by the __OALPLUS_ERROR_NO_FUNC preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns a nullptr.

6

Returns the line of the OALplus source file where the error occured. The result of this function is also influenced by the __OALPLUS_ERROR_NO_LINE preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns zero.

7

This function returns the name of the AL library ("al", "alc", "alut") where the error occured. The result of this function is also influenced by the __OALPLUS_ERROR_NO_AL_LIB preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns nullptr.

8

This function returns the name of the failed OpenAL function (without the al prefix) which is related to the error. The result of this function is also influenced by the __OALPLUS_ERROR_NO_AL_FUNC preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns nullptr.

9

Returns the value of the enumeration parameter related to the error. If no enum parameter is available, this function returns zero. The result of this function is also influenced by the __OALPLUS_ERROR_NO_AL_SYMBOL preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns zero.

10

Returns the name of the enumeration parameter related to the error. If the enum parameter name is not available, this function returns zero. The result of this function is also influenced by the __OALPLUS_ERROR_NO_AL_SYMBOL preprocessor configuration option. If set to zero, this function behaves as described above, otherwise it returns nullptr.

11

If the error is related to a AL object, then an object type enumeration value is returned. Otherwise the result is zero.

12

If the error is related to a AL object, then the numeric AL name of the object is returned. Otherwise the result is a negative integer.

13

If the error is related to a AL object, then a std::string storing object description is returned. Otherwise the result is an empty std::string.

[oalplus_error_Error_2]


PrevUpHomeNext