Changeset 262


Ignore:
Timestamp:
Dec 6, 2002, 11:41:09 AM (18 years ago)
Author:
pooh
Message:
  • Added fields describing information about a place where exception was

thrown.

Location:
to-imperative/trunk/libp++
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/libp++/pxx_sys_error.hh

    r259 r262  
    2424#define __pxx_sys_error_hh__
    2525
     26#include "pxx_common.hh"
     27
    2628namespace pxx
    2729{
     30
     31#define throw_sys_error(n) \
     32  throw SysError(n, __PRETTY_FUNCTION__, __FILE__, __LINE__)
    2833
    2934//
     
    3641  //! Error code
    3742  int err_code ;
     43  //
     44  //!
     45  char const* function ;
     46  //
     47  //!
     48  char const* file ;
     49  //
     50  //!
     51  int line ;
    3852
    3953public:
    4054  //
    4155  //! Constructor
    42   inline SysError (int _code) ;
     56  inline SysError (
     57    int _code, char const* _function = null,
     58    char const* _file = null, int _line = 0
     59  ) ;
    4360  //
    4461  //! Destructor
     
    4764  //! Get error code
    4865  inline int get_code () const ;
     66  //
     67  //! Print an error message
     68  inline void print () ;
    4969
    5070};
  • to-imperative/trunk/libp++/pxx_sys_error.ih

    r259 r262  
    3131//
    3232//! Constructor
    33 inline SysError::SysError (int _code) :
    34   err_code (_code)
     33inline SysError::SysError (
     34  int _code, char const* _function /* = null */,
     35  char const* _file /* = null */, int _line /* = 0 */
     36) :
     37  err_code (_code),
     38  function (_function),
     39  file (_file),
     40  line (_line)
    3541{}
    3642
     
    4652}
    4753
     54//
     55//! Print an error message
     56inline void SysError::print ()
     57{
     58  if (function != null) {
     59    fprintf(
     60      stderr, "System error in %s at %s:%d\n%s\n",
     61      function, file, line, sys_errlist[err_code]
     62    );
     63  } else {
     64    fprintf(stderr, "%s\n", sys_errlist[err_code]);
     65  }
     66}
     67
    4868}
    4969
Note: See TracChangeset for help on using the changeset viewer.