1998-05-13 00:30:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Exceptions.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ostream.h>
|
|
|
|
|
|
|
|
ostream& operator<<(ostream &s, Exception &e)
|
|
|
|
{
|
|
|
|
return s << e.GetMessage() << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::Exception()
|
|
|
|
{
|
|
|
|
mMessage = (char*)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::Exception(const char *aMessage)
|
|
|
|
{
|
|
|
|
size_t size = strlen(aMessage) + 1;
|
|
|
|
mMessage = new char[size];
|
|
|
|
strcpy(mMessage, aMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::~Exception()
|
|
|
|
{
|
|
|
|
if (mMessage) {
|
|
|
|
delete[] mMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::Exception(Exception &aException)
|
|
|
|
{
|
|
|
|
size_t size = strlen(aException.mMessage) + 1;
|
|
|
|
mMessage = new char[size];
|
|
|
|
strcpy(mMessage, aException.mMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Exception::SetMessage(char *aMessage)
|
|
|
|
{
|
|
|
|
if (mMessage) {
|
|
|
|
delete[] mMessage;
|
|
|
|
mMessage = (char*)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aMessage) {
|
|
|
|
size_t size = strlen(aMessage) + 1;
|
|
|
|
mMessage = new char[size];
|
|
|
|
strcpy(mMessage, aMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char* Exception::GetMessage()
|
|
|
|
{
|
|
|
|
return mMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
AbortParser::AbortParser(char *aFileName, long aLineNumber)
|
|
|
|
{
|
|
|
|
char message[512]; // seems big enough
|
|
|
|
char lineNumber[20];
|
|
|
|
strcpy(message, "File: ");
|
|
|
|
strcat(message, aFileName);
|
|
|
|
strcat(message, ". Line Number: ");
|
|
|
|
|
1999-03-06 03:33:35 +03:00
|
|
|
#if defined XP_UNIX || defined XP_MAC
|
1998-12-15 06:24:59 +03:00
|
|
|
sprintf(lineNumber,"%d",aLineNumber);
|
|
|
|
#else
|
1998-05-13 00:30:45 +04:00
|
|
|
itoa(aLineNumber, lineNumber, 10);
|
1998-12-15 06:24:59 +03:00
|
|
|
#endif
|
1998-05-13 00:30:45 +04:00
|
|
|
strcat(message, lineNumber);
|
|
|
|
|
|
|
|
SetMessage(message);
|
|
|
|
}
|
|
|
|
|
1998-05-19 09:21:21 +04:00
|
|
|
FileNotFoundException::FileNotFoundException(char *aFileName)
|
|
|
|
{
|
|
|
|
char message[512]; // seems big enough
|
|
|
|
strcpy(message, "File not found: ");
|
|
|
|
strcat(message, aFileName);
|
|
|
|
|
|
|
|
SetMessage(message);
|
|
|
|
}
|
1998-05-13 00:30:45 +04:00
|
|
|
|
1998-05-19 09:21:21 +04:00
|
|
|
CantOpenFileException::CantOpenFileException(char *aFileName)
|
|
|
|
{
|
|
|
|
char message[512]; // seems big enough
|
|
|
|
strcpy(message, "Can't open file: ");
|
|
|
|
strcat(message, aFileName);
|
|
|
|
|
|
|
|
SetMessage(message);
|
|
|
|
}
|