// BlinkGame - Hunt for the Lost Pixels
// an SDL game in honor of the BlinkenArea crew
//
// (C) 2005-06 Rene Schickbauer
//
// See License.txt for licensing information
//
#ifdef NOP_CODE
/*--------------------------------------------------------------------
		   CVS AUTO-GENERATED INFO
$Author: cavac $
$Date: 2006/03/02 13:03:42 $
$Name: rel-0-3-patches $
$Revision: 1.4 $
$State: Exp $

$Log: errorhandler.cpp,v $
Revision 1.4  2006/03/02 13:03:42  cavac
Re-formatted all .cpp and .h files a bit to get rid of the TAB/SPACE mess
that makes troubles with XCode's "re-format" feature

Revision 1.3  2006/02/27 15:46:30  cavac
Made errors with DIE more visible (added some figlet art)

Revision 1.2  2006/02/17 11:05:06  cavac
Updated VC6 Workspace

Revision 1.1  2006/02/17 10:49:42  cavac
Added error-handling

--------------------------------------------------------------------*/
#endif //NOP_CODE

#include "errorhandler.h"
#include <stdio.h>

#define PARSE_ERRORCODES
char* getErrorText(Uint32 errorcode) {
	static char intErrString[255];
	intErrString[0] = 0;
#define XX(errenum, errcode, errtxt) \
	if(errorcode == errcode) { \
		sprintf(intErrString, "%s", errtxt); \
	}
#include "errorcodes.h"
	return intErrString;
}
#undef PARSE_ERRORCODES

void dieWithError(Uint32 errorcode, char* extrainfo, Uint32 linenum, char* filename) {
	fprintf(stderr, "__          ___                           _ _ \n");
	fprintf(stderr, "\\ \\        / / |                         | | |\n");
	fprintf(stderr, " \\ \\  /\\  / /| |__   ___   ___  _ __  ___| | |\n");
	fprintf(stderr, "  \\ \\/  \\/ / | '_ \\ / _ \\ / _ \\| '_ \\/ __| | |\n");
	fprintf(stderr, "   \\  /\\  /  | | | | (_) | (_) | |_) \\__ \\_|_|\n");
	fprintf(stderr, "    \\/  \\/   |_| |_|\\___/ \\___/| .__/|___(_|_)\n");
	fprintf(stderr, "                               | |            \n");
	fprintf(stderr, "                               |_|            \n");
	fprintf(stderr, "\n");
	fprintf(stderr, "The Blinkensisters team is proud to present you the following fatal error:\n");
	fprintf(stderr, "Error %d: %s\nError-Info: %s\nError at %s:%d\n",
						errorcode, getErrorText(errorcode), extrainfo, filename, linenum);
	fprintf(stderr, "\nPlease report this error to cavac@users.sourceforge.net!\n");
	exit(errorcode);
}
