The throwing of exceptions can now be disabled, and in this case a handler function is called instead.

This commit is contained in:
David Williams
2012-12-29 00:11:23 +00:00
parent 25a4ff1c8e
commit 4f7a6256a9
3 changed files with 30 additions and 8 deletions

View File

@ -21,11 +21,9 @@ freely, subject to the following restrictions:
distribution.
*******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
#include "PolyVoxCore/Impl/Utility.h"
#include <cassert>
#include <stdexcept>
namespace PolyVox
{
//Note: this function only works for inputs which are a power of two and not zero
@ -33,17 +31,17 @@ namespace PolyVox
uint8_t logBase2(uint32_t uInput)
{
//Debug mode validation
assert(uInput != 0);
assert(isPowerOf2(uInput));
POLYVOX_ASSERT(uInput != 0, "Cannot compute the log of zero.");
POLYVOX_ASSERT(isPowerOf2(uInput), "Input must be a power of two in order to compute the log.");
//Release mode validation
if(uInput == 0)
{
throw std::invalid_argument("Cannot compute the log of zero.");
POLYVOX_THROW(std::invalid_argument, "Cannot compute the log of zero.");
}
if(!isPowerOf2(uInput))
{
throw std::invalid_argument("Input must be a power of two in order to compute the log.");
POLYVOX_THROW(std::invalid_argument, "Input must be a power of two in order to compute the log.");
}
uint32_t uResult = 0;