//
// Copyright (C) 2000-2002 Andrey Slepuhin <pooh@msu.ru>
//
// libp++ 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.
//
// libp++ 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 libp++; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// $Source$
// $Revision$
// $Date$
// Author: Andrey Slepuhin <pooh@msu.ru>

#ifndef __pxx_sys_error_hh__
#define __pxx_sys_error_hh__

#include "pxx_common.hh"

namespace pxx
{

#define throw_sys_error(n) \
  throw pxx::SysError(n, __PRETTY_FUNCTION__, __FILE__, __LINE__)

//
// This is the exception type which is thrown when a system error occured.
class SysError
{

private:
  //
  //! Error code
  int err_code ;
  //
  //!
  char const* function ;
  //
  //!
  char const* file ;
  //
  //!
  int line ;

  NO_ASSIGN(SysError)

public:
  //
  //! Constructor
  inline SysError (
    int _code, char const* _function = null,
    char const* _file = null, int _line = 0
  ) ;
  //
  //! Destructor
  inline ~SysError () ;
  //
  //! Get error code
  inline int get_code () const ;
  //
  //! Print an error message
  inline void print () ;

};

}

#endif // __pxx_sys_error_hh__
