|
From: <mik...@us...> - 2003-12-24 10:49:51
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions
In directory sc8-pr-cvs1:/tmp/cvs-serv11724/src/exceptions
Added Files:
Exception.cpp Exception.h ThreadException.cpp
ThreadException.h
Log Message:
24/12/2003 Barbeaux
* Implemented a basic Main program.
* Implemented generic Test handler.
* Implemented generic Exception handler.
* Started first revision of the project.
--- NEW FILE: Exception.cpp ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Exception.h"
/**
* Creates a Exception object with the given code and
* message.
*/
Exception::Exception(int eCode, const string& message) :
runtime_error(message), code(eCode) {
}
/**
* Returns the code number of this exception.
*/
int Exception::getErrorCode() const {
return code;
}
--- NEW FILE: Exception.h ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EXCEPTION_H_
#define _EXCEPTION_H_
#include <string>
#include <stdexcept>
using namespace std;
/**
* Defines a generic Exception object for handling
* exceptions into the program.
*
*/
class Exception : public runtime_error {
protected:
// code of this exception
int code;
public:
/**
* Creates a Exception object.
*
* @param eCode - code number of this exception
* @param message - A message to explain this exception
*/
explicit Exception(int eCode, const string& message);
/**
* Returns the error code of this exception
*
* @return int
*/
int getErrorCode() const;
/**
* Returns the message sent with this exception
*
* @return const string
*/
virtual const string getMessage() const = 0;
};
#endif
--- NEW FILE: ThreadException.cpp ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ThreadException.h"
#include <sstream>
using namespace std;
/**
* Creates a ThreadException object with the given error code and
* message.
*/
ThreadException::ThreadException(ThreadError eCode, const string& message) :
Exception(eCode, message) {
}
/**
* Returns the message sent by this exception, depending the
* error code sent.
*/
const string ThreadException::getMessage() const {
ostringstream message;
// Build error message depending error code
switch(code) {
case MutexError:
message << "MutexError";
break;
default:
message << "UnknownError";
break;
}
message << ": ";
message << what();
return message.str();
}
--- NEW FILE: ThreadException.h ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _THREAD_EXCEPTION_H_
#define _THREAD_EXCEPTION_H_
#include "Exception.h"
enum ThreadError {
MutexError
};
/**
* Defines a Exception for handling threading errors.
*/
class ThreadException : public Exception {
public:
/**
* Creates a Thread exception handler.
*
* @param eCode - code of this exception
* @param message - Message to send to this exception
*/
ThreadException(ThreadError eCode, const string& message);
/**
* Returns the message sent by this Thread exception.
*
* @return const string
*/
virtual const string getMessage() const;
};
#endif
|