libsocket  1.5
socketexception.cc
Go to the documentation of this file.
1 /*
2 ** socketexception.cc
3 ** Login : Julien Lemoine <speedblue@happycoders.org>
4 ** Started on Mon May 12 23:23:27 2003 Julien Lemoine
5 ** $Id: socketexception.cc,v 1.2 2004/06/01 21:30:53 speedblue Exp $
6 **
7 ** Copyright (C) 2003,2004 Julien Lemoine
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU Lesser General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU Lesser General Public License for more details.
17 **
18 ** You should have received a copy of the GNU Lesser General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include "socketexception.hh"
24 
25 namespace Network
26 {
27  std::ostream& operator<<(std::ostream& stream, Exception& e)
28  {
29  e.print(stream);
30  return (stream);
31  }
32 
33 
34  const std::string& Exception::get_error() const
35  {
36  return _error;
37  }
38 
39  const char* Exception::get_file() const
40  {
41  return _file;
42  }
43 
44  int Exception::get_line() const
45  {
46  return _line;
47  }
48 
49  void Exception::print(std::ostream& stream) const
50  {
51  if (_file)
52  stream << _error << " [" << _file << ":" << _line << "]"<<std::endl;
53  else
54  stream << _error << std::endl;
55  }
56 
57 }
Network::Exception::get_line
int get_line() const
Definition: socketexception.cc:44
Network::Exception::_line
int _line
Definition: socketexception.hh:72
Network
Network namespace represent all networks connection.
Definition: localsocket.cc:32
Network::Exception::get_file
const char * get_file() const
Definition: socketexception.cc:39
Network::Exception::_file
const char * _file
Definition: socketexception.hh:71
Network::Exception::get_error
const std::string & get_error() const
Definition: socketexception.cc:34
Network::Exception
This class is the top exception class used in libsocket.
Definition: socketexception.hh:47
Network::Exception::_error
std::string _error
Definition: socketexception.hh:70
Network::Exception::print
void print(std::ostream &stream) const
Definition: socketexception.cc:49
Network::operator<<
Socket & operator<<(Socket &s, const std::string &str)
write a string on current socket
Definition: socket.cc:367
socketexception.hh