[8787] Cleanup in Errors.h.

This commit is contained in:
XTZGZoReX 2009-11-08 11:38:00 +01:00
parent 33d475caf3
commit 611b17a431
3 changed files with 49 additions and 15 deletions

View file

@ -22,22 +22,56 @@
#include "Common.h"
#ifndef HAVE_CONFIG_H
#define HAVE_ACE_STACK_TRACE_H 1
# define HAVE_ACE_STACK_TRACE_H 1
#endif
#ifdef HAVE_ACE_STACK_TRACE_H
#include "ace/Stack_Trace.h"
# include "ace/Stack_Trace.h"
#endif
#ifdef HAVE_ACE_STACK_TRACE_H // old versions ACE not have Stack_Trace.h but used at some oS for better compatibility
#define WPAssert( assertion ) { if (!(assertion)) { ACE_Stack_Trace st; fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__,__FUNCTION__, #assertion, st.c_str()); assert( #assertion &&0 ); } }
#ifdef HAVE_ACE_STACK_TRACE_H
// Normal assert.
#define WPError(CONDITION) \
if (!(CONDITION)) \
{ \
ACE_Stack_Trace st; \
printf("%s:%i: Error: Assertion in %s failed: %s\nStack Trace:\n%s", \
__FILE__, __LINE__, __FUNCTION__, STRINGIZE(CONDITION), st.c_str()); \
assert(STRINGIZE(CONDITION) && 0); \
}
// Just warn.
#define WPWarning(CONDITION) \
if (!(CONDITION)) \
{ \
ACE_Stack_Trace st; \
printf("%s:%i: Warning: Assertion in %s failed: %s\nStack Trace:\n%s",\
__FILE__, __LINE__, __FUNCTION__, STRINGIZE(CONDITION), st.c_str()); \
}
#else
#define WPAssert( assertion ) { if (!(assertion)) { fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED2:\n %s\n", __FILE__, __LINE__,__FUNCTION__, #assertion); assert( #assertion &&0 ); } }
#endif
#define WPError( assertion, errmsg ) if( ! (assertion) ) { sLog.outError( "%\n%s:%i in %s ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg ); assert( false ); }
#define WPWarning( assertion, errmsg ) if( ! (assertion) ) { sLog.outError( "\n%s:%i in %s WARNING:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg ); }
// Normal assert.
#define WPError(CONDITION) \
if (!(CONDITION)) \
{ \
printf("%s:%i: Error: Assertion in %s failed: %s", \
__FILE__, __LINE__, __FUNCTION__, STRINGIZE(CONDITION)); \
assert(STRINGIZE(CONDITION) && 0); \
}
// Just warn.
#define WPWarning(CONDITION) \
if (!(CONDITION)) \
{ \
ACE_Stack_Trace st; \
printf("%s:%i: Warning: Assertion in %s failed: %s",\
__FILE__, __LINE__, __FUNCTION__, STRINGIZE(CONDITION)); \
}
#endif
#ifdef MANGOS_DEBUG
# define ASSERT WPError
#else
# define ASSERT WPError // Error even if in release mode.
#endif
#define WPFatal( assertion, errmsg ) if( ! (assertion) ) { sLog.outError( "\n%s:%i in %s FATAL ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg ); assert( #assertion &&0 ); abort(); }
#define ASSERT WPAssert
#endif