Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions
In directory sc8-pr-cvs1:/tmp/cvs-serv19348/src/exceptions
Modified Files:
HttpException.cpp
Added Files:
ServletException.h ServletException.cpp
Log Message:
30/12/2003 Mikael Barbeaux
* Implemented first versions of HttpServletRequest, HttpServletResponse and
ServletException.
* Implemented HttpServlet object.
--- NEW FILE: ServletException.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 _SERVLET_EXCEPTION_H_
#define _SERVLET_EXCEPTION_H_
#include "Exception.h"
enum ServletError {
BadServletRequestExcp
};
/**
* Defines a Exception for handling servlet errors.
*/
class ServletException : public Exception {
public:
/**
* Creates a Servlet exception handler.
*
* @param eCode - code of this exception
* @param message - Message to send to this exception
* @param origin - Method who throws the exception
*/
ServletException(ServletError eCode, const string& message,
const string& origin);
/**
* Returns the message sent by this Servlet exception.
*
* @return const string
*/
virtual const string getMessage() const;
};
#endif
--- NEW FILE: ServletException.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 "ServletException.h"
#include <sstream>
using namespace std;
/**
* Creates a ServletException object with the given error code and
* message.
*/
ServletException::ServletException(ServletError eCode, const string& message,
const string& origin) : Exception(eCode, message, origin) {
}
/**
* Returns the message sent by this exception, depending the
* error code sent.
*/
const string ServletException::getMessage() const {
ostringstream message;
// Build error message depending error code
message << "-----------------------" << endl;
message << "WARNING : ServletException thrown !!" << endl;
message << "| Type : ";
switch(code) {
case BadServletRequestExcp:
message << "BadServletRequest error";
default:
message << "UnknownError";
break;
}
message << endl << "| From : " << origin << endl;
message << "| Message : " << what() << endl;
message << "-----------------------" << endl;
return message.str();
}
Index: HttpException.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/HttpException.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- HttpException.cpp 26 Dec 2003 22:56:42 -0000 1.1
+++ HttpException.cpp 30 Dec 2003 12:08:19 -0000 1.2
@@ -40,6 +40,9 @@
message << "WARNING : HttpException thrown !!" << endl;
message << "| Type : ";
switch(code) {
+ case NotHttpRequestExcp:
+ message << "BadHttpRequest error";
+ break;
default:
message << "UnknownError";
break;
|