src/platform/openal/OpenAlPlayer.cpp
// Note: when used in destructor set abortOnError to true, to avoid throwing in destructor
when used in destructor set abortOnError to true, to avoid throwing in destructor
when used in destructor set abortOnError to true to avoid throwing in destructor
void checkAlError(std::string const& tag, bool abortOnError = false) {
	auto errorCode = alGetError();
	if (errorCode == AL_NO_ERROR) {
		return;
	}
	std::string errorLabel;	
	switch (errorCode) {
	case AL_INVALID_NAME:
		errorLabel = "AL_INVALID_NAME";
		break;
	case AL_INVALID_ENUM:
		errorLabel = "AL_INVALID_ENUM";
		break;
	case AL_INVALID_VALUE:
		errorLabel = "AL_INVALID_VALUE";
		break;
	case AL_INVALID_OPERATION:
		errorLabel = "AL_INVALID_OPERATION";
		break;
	case AL_OUT_OF_MEMORY:
		errorLabel = "AL_OUT_OF_MEMORY";
		break;
	default:
		errorLabel = "UNSPECIFIED ERROR";
		break;
	}
	std::string errorMsg = (boost::format("AL error, %s %s (%d)") 
			% tag % errorLabel % errorCode).str();
	LOGE(errorMsg);
	if (abortOnError) {
		std::abort();
	} else {
		throw std::runtime_error(errorMsg);
	}
}
void checkAlError ( std :: string const & tag , bool abortOnError = false ) { auto errorCode = alGetError ( ) ; if ( errorCode == AL_NO_ERROR ) { return ; } std :: string errorLabel ; switch ( errorCode ) { case AL_INVALID_NAME : errorLabel = " " ; break ; case AL_INVALID_ENUM : errorLabel = " " ; break ; case AL_INVALID_VALUE : errorLabel = " " ; break ; case AL_INVALID_OPERATION : errorLabel = " " ; break ; case AL_OUT_OF_MEMORY : errorLabel = " " ; break ; default : errorLabel = " " ; break ; } std :: string errorMsg = ( boost :: format ( " " ) % tag % errorLabel % errorCode ) . str ( ) ; LOGE ( errorMsg ) ; if ( abortOnError ) { std :: abort ( ) ; } else { throw std :: runtime_error ( errorMsg ) ; } }
Note: when used in destructor set abortOnError to true, to avoid throwing in destructor
Note : when used in destructor set abortOnError to true to avoid throwing in destructor