Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions In directory sc8-pr-cvs1:/tmp/cvs-serv3848/src/exceptions Modified Files: SocketException.h SocketException.cpp Added Files: WriterException.h HttpException.cpp HttpException.h WriterException.cpp Log Message: 26/12/2003 Mikael Barbeaux * Added a test program for Http sockets. * Fixed a problem about accepting sockets which were an infinite process. * Implemented main http controls : HttpRequest, HttpResponse, HttpSocket, HttpServerSocket and Writers --- NEW FILE: WriterException.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 _WRITER_EXCEPTION_H_ #define _WRITER_EXCEPTION_H_ #include "Exception.h" enum WriterError { NotClosedWriterExcp, ClosedWriterExcp }; /** * Defines a Exception for handling writer errors. */ class WriterException : public Exception { public: /** * Creates a Writer exception handler. * * @param eCode - code of this exception * @param message - Message to send to this exception * @param origin - Method who throws the exception */ WriterException(WriterError eCode, const string& message, const string& origin); /** * Returns the message sent by this Writer exception. * * @return const string */ virtual const string getMessage() const; }; #endif --- NEW FILE: HttpException.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 "HttpException.h" #include <sstream> using namespace std; /** * Creates a HttpException object with the given error code and * message. */ HttpException::HttpException(HttpError 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 HttpException::getMessage() const { ostringstream message; // Build error message depending error code message << "-----------------------" << endl; message << "WARNING : HttpException thrown !!" << endl; message << "| Type : "; switch(code) { default: message << "UnknownError"; break; } message << endl << "| From : " << origin << endl; message << "| Message : " << what() << endl; message << "-----------------------" << endl; return message.str(); } --- NEW FILE: HttpException.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 _HTTP_EXCEPTION_H_ #define _HTTP_EXCEPTION_H_ #include "Exception.h" enum HttpError { NotHttpRequestExcp }; /** * Defines a Exception for handling http errors. */ class HttpException : public Exception { public: /** * Creates a Http exception handler. * * @param eCode - code of this exception * @param message - Message to send to this exception * @param origin - Method who throws the exception */ HttpException(HttpError eCode, const string& message, const string& origin); /** * Returns the message sent by this Http exception. * * @return const string */ virtual const string getMessage() const; }; #endif --- NEW FILE: WriterException.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 "WriterException.h" #include <sstream> using namespace std; /** * Creates a WriterException object with the given error code and * message. */ WriterException::WriterException(WriterError 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 WriterException::getMessage() const { ostringstream message; // Build error message depending error code message << "-----------------------" << endl; message << "WARNING : WriterException thrown !!" << endl; message << "| Type : "; switch(code) { case NotClosedWriterExcp: message << "NotClosedWriter error"; break; case ClosedWriterExcp: message << "ClosedWriter error"; break; default: message << "UnknownError"; break; } message << endl << "| From : " << origin << endl; message << "| Message : " << what() << endl; message << "-----------------------" << endl; return message.str(); } Index: SocketException.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/SocketException.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SocketException.h 26 Dec 2003 10:04:50 -0000 1.1 +++ SocketException.h 26 Dec 2003 22:56:42 -0000 1.2 @@ -33,7 +33,8 @@ CantBindSockExcp, UnboundSockExcp, CantListenSockExcp, - NotListeningSockExcp + NotListeningSockExcp, + NotAcceptedSockExcp }; /** Index: SocketException.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/SocketException.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SocketException.cpp 26 Dec 2003 10:04:50 -0000 1.1 +++ SocketException.cpp 26 Dec 2003 22:56:42 -0000 1.2 @@ -40,6 +40,9 @@ message << "WARNING : SocketException thrown !!" << endl; message << "| Type : "; switch(code) { + case NotAcceptedSockExcp: + message << "NotAcceptedSocket error"; + break; case InvalidSockExcp: message << "InvalidSocket error"; break; |