socketexception.hh
Go to the documentation of this file.
/*
** socketexception.hh
** Login : Julien Lemoine <speedblue@happycoders.org>
** Started on Mon May 12 22:50:50 2003 Julien Lemoine
** $Id: socketexception.hh,v 1.6 2004/06/06 14:13:56 speedblue Exp $
**
** Copyright (C) 2003,2004 Julien Lemoine
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser 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 SOCKETEXCEPTION_HH_
# define SOCKETEXCEPTION_HH_
#define HERE __FILE__, __LINE__
#include <iostream>
#include <string>
#define NEW_EXCEPTION(Name) \
class Name : public Exception \
{ \
public: \
Name(const std::string& desc, const char * file, int line) : \
Exception(desc, file, line) \
{} \
Name() : Exception() {} \
Name(const char *file, int line) : Exception(file, line) {} \
};
namespace Network
{
class Exception
{
public:
Exception() :
_error("Exception Occured"), _file(0x0), _line(0)
{}
Exception(const char *file, int line) :
_error("Exception Occured"), _file(file), _line(line)
{}
Exception(const std::string& err, const char* file, int line) :
_file(file), _line(line)
{
_error = "Exception: " + err;
}
void print(std::ostream& stream) const;
const std::string& get_error() const;
const char* get_file() const;
int get_line() const;
protected:
std::string _error;
const char* _file;
int _line;
};
std::ostream& operator<<(std::ostream& stream, Exception& e);
NEW_EXCEPTION(HostnameError);
NEW_EXCEPTION(Ipv6SupportError);
NEW_EXCEPTION(TLSError);
NEW_EXCEPTION(InvalidFile);
NEW_EXCEPTION(TLSSupportError);
NEW_EXCEPTION(InetptonError);
NEW_EXCEPTION(InetntopError);
NEW_EXCEPTION(ConnectionClosed);
NEW_EXCEPTION(NoConnection);
NEW_EXCEPTION(Timeout);
NEW_EXCEPTION(BindError);
NEW_EXCEPTION(SocketError);
NEW_EXCEPTION(ListenError);
NEW_EXCEPTION(SetsockoptError);
NEW_EXCEPTION(CloseError);
NEW_EXCEPTION(SelectError);
NEW_EXCEPTION(ConnectError);
NEW_EXCEPTION(AcceptError);
NEW_EXCEPTION(GetpeernameError);
NEW_EXCEPTION(WSAStartupError);
}
#endif /* !SOCKETEXCEPTION_HH_ */
Network::Exception
This class is the top exception class used in libsocket.
Definition socketexception.hh:48
Network::Exception::_file
const char * _file
Definition socketexception.hh:71
Network::Exception::get_line
int get_line() const
Definition socketexception.cc:44
Network::Exception::get_error
const std::string & get_error() const
Definition socketexception.cc:34
Network::Exception::_line
int _line
Definition socketexception.hh:72
Network::Exception::print
void print(std::ostream &stream) const
Definition socketexception.cc:49
Network::Exception::get_file
const char * get_file() const
Definition socketexception.cc:39
Network::Exception::Exception
Exception(const std::string &err, const char *file, int line)
Definition socketexception.hh:58
Network::Exception::Exception
Exception()
Definition socketexception.hh:50
Network::Exception::Exception
Exception(const char *file, int line)
Definition socketexception.hh:54
Network::Exception::_error
std::string _error
Definition socketexception.hh:70
Network
Network namespace represent all networks connection.
Definition localsocket.cc:33
Network::operator<<
Socket & operator<<(Socket &s, const std::string &str)
write a string on current socket
Definition socket.cc:367
NEW_EXCEPTION
#define NEW_EXCEPTION(Name)
Definition socketexception.hh:31