Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "bitbuf.h"
  8. #include "bitbuf_errorhandler.h"
  9. #include "tier0/dbg.h"
  10. #include "utlsymbol.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. void EngineBitBufErrorHandler( BitBufErrorType errorType, const char *pDebugName )
  14. {
  15. if ( !pDebugName )
  16. {
  17. pDebugName = "(unknown)";
  18. }
  19. static CUtlSymbolTable errorNames[ BITBUFERROR_NUM_ERRORS ];
  20. // Only print an error a couple times.
  21. CUtlSymbol sym = errorNames[ errorType ].Find( pDebugName );
  22. if ( UTL_INVAL_SYMBOL == sym )
  23. {
  24. errorNames[ errorType ].AddString( pDebugName );
  25. if ( errorType == BITBUFERROR_VALUE_OUT_OF_RANGE )
  26. {
  27. Warning( "Error in bitbuf [%s]: out of range value. Debug in bitbuf_errorhandler.cpp\n", pDebugName );
  28. }
  29. else if ( errorType == BITBUFERROR_BUFFER_OVERRUN )
  30. {
  31. Warning( "Error in bitbuf [%s]: buffer overrun. Debug in bitbuf_errorhandler.cpp\n", pDebugName );
  32. }
  33. }
  34. AssertMsg( false, "%s: %s errorType: %d", __FUNCTION__, pDebugName, errorType );
  35. }
  36. void InstallBitBufErrorHandler()
  37. {
  38. SetBitBufErrorHandler( EngineBitBufErrorHandler );
  39. }