Skip to content

Commit

Permalink
Main: add two-argument OGRE_EXCEPT using __FUNCTION__ as src
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Nov 1, 2018
1 parent f2a5a94 commit 5edf8c1
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 119 deletions.
3 changes: 1 addition & 2 deletions Components/Overlay/src/OgreOverlayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Getting ViewPort orientation mode is not supported",
__FUNCTION__);
"Getting ViewPort orientation mode is not supported");
#endif
return mLastViewportOrientationMode;
}
Expand Down
8 changes: 3 additions & 5 deletions Components/Terrain/src/OgreTerrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,7 @@ namespace Ogre
load();
else
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Error while preparing " + filename + ", see log for details",
__FUNCTION__);
"Error while preparing " + filename + ", see log for details");
}
//---------------------------------------------------------------------
void Terrain::load(StreamSerialiser& stream)
Expand All @@ -1137,8 +1136,7 @@ namespace Ogre
load();
else
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Error while preparing from stream, see log for details",
__FUNCTION__);
"Error while preparing from stream, see log for details");
}
//---------------------------------------------------------------------
void Terrain::load(int lodLevel, bool synchronous)
Expand Down Expand Up @@ -4335,7 +4333,7 @@ namespace Ogre
{
if (isLoaded())
OGRE_EXCEPT(Exception::ERR_INVALID_STATE,
"Cannot alter the allocator when loaded!", __FUNCTION__);
"Cannot alter the allocator when loaded!");

mCustomGpuBufferAllocator = alloc;
}
Expand Down
3 changes: 1 addition & 2 deletions Components/Terrain/src/OgreTerrainGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,7 @@ namespace Ogre
void TerrainGroup::loadGroupDefinition(StreamSerialiser& ser)
{
if (!ser.readChunkBegin(CHUNK_ID, CHUNK_VERSION))
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Stream does not contain TerrainGroup data", __FUNCTION__);
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Stream does not contain TerrainGroup data");

// Base details
ser.read(&mAlignment);
Expand Down
6 changes: 2 additions & 4 deletions Components/Terrain/src/OgreTerrainMaterialShaderHelperCg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ namespace Ogre
if (texCoordSet > 8)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Requested options require too many texture coordinate sets! Try reducing the number of layers.",
__FUNCTION__);
"Requested options require too many texture coordinate sets! Try reducing the number of layers.");
}

outStream <<
Expand Down Expand Up @@ -387,8 +386,7 @@ namespace Ogre
if (currentSamplerIdx > 16)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Requested options require too many texture samplers! Try reducing the number of layers.",
__FUNCTION__);
"Requested options require too many texture samplers! Try reducing the number of layers.");
}

outStream <<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ namespace Ogre
if (texCoordSet > 8)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Requested options require too many texture coordinate sets! Try reducing the number of layers.",
__FUNCTION__);
"Requested options require too many texture coordinate sets! Try reducing the number of layers.");
}

outStream << "void main(void) {\n";
Expand Down Expand Up @@ -361,8 +360,7 @@ namespace Ogre
if (currentSamplerIdx > 16)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Requested options require too many texture samplers! Try reducing the number of layers.",
__FUNCTION__);
"Requested options require too many texture samplers! Try reducing the number of layers.");
}

outStream << "void main(void) {\n"
Expand Down
4 changes: 1 addition & 3 deletions Components/Volume/src/OgreVolumeChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ namespace Volume {
if (parameters->baseError == (Real)0.0 || parameters->errorMultiplicator == (Real)0.0 ||
parameters->sceneManager == 0 || parameters->src == 0)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Invalid parameters given!",
__FUNCTION__);
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid parameters given!");
}

isRoot = true;
Expand Down
4 changes: 1 addition & 3 deletions Components/Volume/src/OgreVolumeHalfFloatGridSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ namespace Volume {
#endif
if (!ser.readChunkBegin(VOLUME_CHUNK_ID, VOLUME_CHUNK_VERSION))
{
OGRE_EXCEPT(Exception::ERR_INVALID_STATE,
"Invalid volume file given!",
__FUNCTION__);
OGRE_EXCEPT(Exception::ERR_INVALID_STATE, "Invalid volume file given!");
}

// Read header
Expand Down
4 changes: 2 additions & 2 deletions OgreMain/include/OgreCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace Ogre {
{
CodecList::iterator i = msMapCodecs.find(pCodec->getType());
if (i != msMapCodecs.end())
OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
pCodec->getType() + " already has a registered codec. ", __FUNCTION__);
OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
pCodec->getType() + " already has a registered codec.");

msMapCodecs[pCodec->getType()] = pCodec;
}
Expand Down
10 changes: 7 additions & 3 deletions OgreMain/include/OgreException.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ THE SOFTWARE.
# if OGRE_DEBUG_MODE
# define OgreAssert( a, b ) assert( (a) && (b) )
# else
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNCTION__ )
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT_2( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b) )
# endif

// EXCEPTIONS mode
#elif OGRE_ASSERT_MODE == 2
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNCTION__ )
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT_2( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b) )
// STANDARD mode
#else
/** Checks a condition at runtime and throws exception/ aborts if it fails.
Expand Down Expand Up @@ -285,7 +285,11 @@ namespace Ogre {


#ifndef OGRE_EXCEPT
#define OGRE_EXCEPT(code, desc, src) Ogre::ExceptionFactory::throwException(code, desc, src, __FILE__, __LINE__)
#define OGRE_EXCEPT_3(code, desc, src) Ogre::ExceptionFactory::throwException(code, desc, src, __FILE__, __LINE__)
#define OGRE_EXCEPT_2(code, desc) Ogre::ExceptionFactory::throwException(code, desc, __FUNCTION__, __FILE__, __LINE__)
#define OGRE_EXCEPT_CHOOSER(arg1, arg2, arg3, arg4, ...) arg4
#define OGRE_EXPAND(x) x // MSVC workaround
#define OGRE_EXCEPT(...) OGRE_EXPAND(OGRE_EXCEPT_CHOOSER(__VA_ARGS__, OGRE_EXCEPT_3, OGRE_EXCEPT_2)(__VA_ARGS__))
#endif
/** @} */
/** @} */
Expand Down
6 changes: 2 additions & 4 deletions OgreMain/src/OgreFrustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Setting Frustrum orientation mode is not supported",
__FUNCTION__);
"Setting Frustrum orientation mode is not supported");
#endif
mOrientationMode = orientationMode;
invalidateFrustum();
Expand All @@ -1349,8 +1348,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Getting Frustrum orientation mode is not supported",
__FUNCTION__);
"Getting Frustrum orientation mode is not supported");
#endif
return mOrientationMode;
}
Expand Down
9 changes: 3 additions & 6 deletions OgreMain/src/OgreMeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ namespace Ogre
{
if ((params.xsegments + 1) * (params.ysegments + 1) > 65536)
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Plane tessellation is too high, must generate max 65536 vertices",
__FUNCTION__);
"Plane tessellation is too high, must generate max 65536 vertices");
SubMesh *pSub = pMesh->createSubMesh();

// Set up vertex data
Expand Down Expand Up @@ -578,8 +577,7 @@ namespace Ogre
{
if ((params.xsegments + 1) * (params.ysegments + 1) > 65536)
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Plane tessellation is too high, must generate max 65536 vertices",
__FUNCTION__);
"Plane tessellation is too high, must generate max 65536 vertices");
SubMesh *pSub = pMesh->createSubMesh();

// Set options
Expand Down Expand Up @@ -736,8 +734,7 @@ namespace Ogre

if ((params.xsegments + 1) * (params.ySegmentsToKeep + 1) > 65536)
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Plane tessellation is too high, must generate max 65536 vertices",
__FUNCTION__);
"Plane tessellation is too high, must generate max 65536 vertices");
SubMesh *pSub = pMesh->createSubMesh();


Expand Down
6 changes: 2 additions & 4 deletions OgreMain/src/OgrePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,7 @@ namespace Ogre {
if (!programUsage)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"This pass does not have this program type assigned!",
__FUNCTION__);
"This pass does not have this program type assigned!");
}
programUsage->setParameters(params);
}
Expand Down Expand Up @@ -1338,8 +1337,7 @@ namespace Ogre {
if (!programUsage)
{
OGRE_EXCEPT (Exception::ERR_INVALIDPARAMS,
"This pass does not have this program type assigned!",
__FUNCTION__);
"This pass does not have this program type assigned!");
}
return programUsage->getParameters();
}
Expand Down
5 changes: 2 additions & 3 deletions OgreMain/src/OgreRoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ namespace Ogre {
{
OGRE_DELETE_T(fs, basic_fstream, MEMCATEGORY_GENERAL);
OGRE_EXCEPT(Exception::ERR_CANNOT_WRITE_TO_FILE,
"Can't open " + filename + " for writing", __FUNCTION__);
"Can't open " + filename + " for writing");
}

stream = DataStreamPtr(OGRE_NEW FileStreamDataStream(filename, fs));
Expand All @@ -1076,8 +1076,7 @@ namespace Ogre {
if(!*ifs)
{
OGRE_DELETE_T(ifs, basic_ifstream, MEMCATEGORY_GENERAL);
OGRE_EXCEPT(
Exception::ERR_FILE_NOT_FOUND, "'" + filename + "' file not found!", __FUNCTION__);
OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, "'" + filename + "' file not found!");
}
return DataStreamPtr(OGRE_NEW FileStreamDataStream(filename, ifs));
}
Expand Down
12 changes: 4 additions & 8 deletions OgreMain/src/OgreViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Setting Viewport orientation mode is not supported",
__FUNCTION__);
"Setting Viewport orientation mode is not supported");
#endif
mOrientationMode = orientationMode;

Expand Down Expand Up @@ -256,8 +255,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Getting Viewport orientation mode is not supported",
__FUNCTION__);
"Getting Viewport orientation mode is not supported");
#endif
return mOrientationMode;
}
Expand All @@ -266,8 +264,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Setting default Viewport orientation mode is not supported",
__FUNCTION__);
"Setting default Viewport orientation mode is not supported");
#endif
mDefaultOrientationMode = orientationMode;
}
Expand All @@ -276,8 +273,7 @@ namespace Ogre {
{
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
"Getting default Viewport orientation mode is not supported",
__FUNCTION__);
"Getting default Viewport orientation mode is not supported");
#endif
return mDefaultOrientationMode;
}
Expand Down
5 changes: 2 additions & 3 deletions PlugIns/FreeImageCodec/src/OgreFreeImageCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ namespace Ogre {
if (conversionRequired)
OGRE_FREE(convBox.data, MEMCATEGORY_GENERAL);

OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"FreeImage_AllocateT failed - possibly out of memory. ",
__FUNCTION__);
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"FreeImage_AllocateT failed - possibly out of memory. ");
}

if (requiredFormat == PF_L8 || requiredFormat == PF_A8)
Expand Down
2 changes: 1 addition & 1 deletion PlugIns/STBICodec/src/OgreSTBICodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static Ogre::uchar* custom_zlib_compress(Ogre::uchar* data, int data_len, int* o
if (ret != Z_OK)
{
free(dest);
OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "compress failed", __FUNCTION__);
OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "compress failed");
}

*out_len = destLen;
Expand Down
4 changes: 1 addition & 3 deletions RenderSystems/GLES2/src/EAGL/OgreEAGL2Support.mm
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ void load(EAGL2Support* const glSupport, CFDictionaryRef glConfig)
EAGLES2Context *context = new EAGLES2Context(drawable, group);
if (context == NULL)
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Fail to create new context",
__FUNCTION__);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Fail to create new context");
return context;
}

Expand Down
6 changes: 2 additions & 4 deletions RenderSystems/GLES2/src/EAGL/OgreEAGL2Window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@ of this software and associated documentation files (the "Software"), to deal
if ([mContext->getContext() presentRenderbuffer:GL_RENDERBUFFER] == NO)
{
glGetError();
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to swap buffers in ",
__FUNCTION__);
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to swap buffers in ");
}
}

Expand Down Expand Up @@ -479,7 +477,7 @@ of this software and associated documentation files (the "Software"), to deal
|| dst.getWidth() != src.getWidth() || dst.getHeight() != src.getHeight() || dst.getDepth() != 1
|| dst.getWidth() != dst.rowPitch /* GLES2 does not support GL_PACK_ROW_LENGTH, nor iOS supports GL_NV_pack_subimage */)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid box.", __FUNCTION__ );
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid box.");
}

if (buffer == FB_AUTO)
Expand Down
15 changes: 5 additions & 10 deletions RenderSystems/GLES2/src/EAGL/OgreEAGLES2Context.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ of this software and associated documentation files (the "Software"), to deal
if (!mContext || ![EAGLContext setCurrentContext:mContext])
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Unable to create a suitable EAGLContext",
__FUNCTION__);
"Unable to create a suitable EAGLContext");
}

#ifdef __IPHONE_7_1
Expand Down Expand Up @@ -115,8 +114,7 @@ of this software and associated documentation files (the "Software"), to deal
{
glGetError();
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to bind the drawable to a renderbuffer object",
__FUNCTION__);
"Failed to bind the drawable to a renderbuffer object");
return false;
}

Expand Down Expand Up @@ -159,8 +157,7 @@ of this software and associated documentation files (the "Software"), to deal
{
glGetError();
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to make a complete FSAA framebuffer object",
__FUNCTION__);
"Failed to make a complete FSAA framebuffer object");
return false;
}
}
Expand All @@ -182,8 +179,7 @@ of this software and associated documentation files (the "Software"), to deal
{
glGetError();
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to make a complete framebuffer object",
__FUNCTION__);
"Failed to make a complete framebuffer object");
return false;
}

Expand Down Expand Up @@ -229,8 +225,7 @@ of this software and associated documentation files (the "Software"), to deal
if (!ret)
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to make context current",
__FUNCTION__);
"Failed to make context current");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ namespace Ogre {
if (eglGetConfigAttrib(mGLDisplay, configs[config], attribList[attrib], &value) == EGL_FALSE)
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Failed to get config attribute",
__FUNCTION__);
"Failed to get config attribute");

*nElements = 0;
free(configs);
Expand Down
Loading

0 comments on commit 5edf8c1

Please sign in to comment.