summaryrefslogtreecommitdiff
path: root/engine/bitbuf_errorhandler.cpp
blob: df4f698e24039fb83a737da2644f36b2c0cd05ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "bitbuf.h"
#include "bitbuf_errorhandler.h"
#include "tier0/dbg.h"
#include "utlsymbol.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

void EngineBitBufErrorHandler( BitBufErrorType errorType, const char *pDebugName )
{
	if ( !pDebugName )
	{
		pDebugName = "(unknown)";
	}

	static CUtlSymbolTable errorNames[ BITBUFERROR_NUM_ERRORS ];

	// Only print an error a couple times.
	CUtlSymbol sym = errorNames[ errorType ].Find( pDebugName );
	if ( UTL_INVAL_SYMBOL == sym )
	{
		errorNames[ errorType ].AddString( pDebugName );
		if ( errorType == BITBUFERROR_VALUE_OUT_OF_RANGE )
		{
			Warning( "Error in bitbuf [%s]: out of range value. Debug in bitbuf_errorhandler.cpp\n", pDebugName );
		}
		else if ( errorType == BITBUFERROR_BUFFER_OVERRUN )
		{
			Warning( "Error in bitbuf [%s]: buffer overrun. Debug in bitbuf_errorhandler.cpp\n", pDebugName );
		}
	}

	AssertMsg( false, "%s: %s errorType: %d", __FUNCTION__, pDebugName, errorType );
}

void InstallBitBufErrorHandler()
{
	SetBitBufErrorHandler( EngineBitBufErrorHandler );
}