libsocket  1.5
Network::Exception Class Reference

This class is the top exception class used in libsocket. More...

#include <socketexception.hh>

Public Member Functions

 Exception ()
 
 Exception (const char *file, int line)
 
 Exception (const std::string &err, const char *file, int line)
 
void print (std::ostream &stream) const
 
const std::string & get_error () const
 
const char * get_file () const
 
int get_line () const
 

Protected Attributes

std::string _error
 
const char * _file
 
int _line
 

Detailed Description

This class is the top exception class used in libsocket.

Author
Julien Lemoine <speedblue at happycoders dot org>

Definition at line 47 of file socketexception.hh.

Constructor & Destructor Documentation

◆ Exception() [1/3]

Network::Exception::Exception ( )
inline

Definition at line 50 of file socketexception.hh.

50  :
51  _error("Exception Occured"), _file(0x0), _line(0)
52  {}

◆ Exception() [2/3]

Network::Exception::Exception ( const char *  file,
int  line 
)
inline

Definition at line 54 of file socketexception.hh.

54  :
55  _error("Exception Occured"), _file(file), _line(line)
56  {}

◆ Exception() [3/3]

Network::Exception::Exception ( const std::string &  err,
const char *  file,
int  line 
)
inline

Definition at line 58 of file socketexception.hh.

58  :
59  _file(file), _line(line)
60  {
61  _error = "Exception: " + err;
62  }

References _error.

Member Function Documentation

◆ get_error()

const std::string & Network::Exception::get_error ( ) const

Definition at line 34 of file socketexception.cc.

35  {
36  return _error;
37  }

References _error.

◆ get_file()

const char * Network::Exception::get_file ( ) const

Definition at line 39 of file socketexception.cc.

40  {
41  return _file;
42  }

References _file.

◆ get_line()

int Network::Exception::get_line ( ) const

Definition at line 44 of file socketexception.cc.

45  {
46  return _line;
47  }

References _line.

◆ print()

void Network::Exception::print ( std::ostream &  stream) const

Definition at line 49 of file socketexception.cc.

50  {
51  if (_file)
52  stream << _error << " [" << _file << ":" << _line << "]"<<std::endl;
53  else
54  stream << _error << std::endl;
55  }

References _error, _file, and _line.

Referenced by Network::operator<<().

Member Data Documentation

◆ _error

std::string Network::Exception::_error
protected

Definition at line 70 of file socketexception.hh.

Referenced by Exception(), get_error(), and print().

◆ _file

const char* Network::Exception::_file
protected

Definition at line 71 of file socketexception.hh.

Referenced by get_file(), and print().

◆ _line

int Network::Exception::_line
protected

Definition at line 72 of file socketexception.hh.

Referenced by get_line(), and print().


The documentation for this class was generated from the following files:
Network::Exception::_line
int _line
Definition: socketexception.hh:72
Network::Exception::_file
const char * _file
Definition: socketexception.hh:71
Network::Exception::_error
std::string _error
Definition: socketexception.hh:70