#include "AllTools.h"

static char *errorStrings[] = {
				"\p<no error>",
				"\pThe Menu resource I require is not in the Resource Fork",
				"\pgestalt not available",
				"\pthere are no session spaces available",
				"\pI cant find a dialog I need",
				"\pNot enough memory for operation",
				"\pNot enough memory to continue, Please allocate more memory to Application",
				"\pFile error",
				"\pDisk is locked",
				"\pFile is locked",
				"\pCant evaluate recursive functions",
				"\pControl does not exist",
				"\pFunction Error"
				"\pCannot find window resource",
				"\pSheet does not exist",
				"\pThat cell is out of range",
				"\pInvalid row or column",
				"\pYou need an 8bit capable computer to run this Application",
				"\pError in creating control"
				};

void DoError(short theCode, Boolean Exit)
{
DialogPtr	theDialog;
Boolean 	itsDone;
short		itemHit;

FlushEvents(everyEvent, REMOVE_ALL_EVENTS);
SysBeep(1);
if (Exit == TRUE)	theDialog = GetNewDialog(fatalErrorDialog, nil, (WindowPtr)-1);
if (Exit == FALSE)	theDialog = GetNewDialog(badErrorDialog  , nil, (WindowPtr)-1);
if (theDialog == 0) ExitToShell();

SetTheInfoStr(theDialog, ierrorText, errorStrings[theCode]);

itsDone = FALSE;

while(itsDone == FALSE)
	{
		ModalDialog(nil, &itemHit);
		
		if (itemHit == iOK) itsDone = TRUE;
	}

CloseDialog(theDialog);

if (Exit == TRUE)	ExitToShell();
}