File: minc_io_exceptions.h

package info (click to toggle)
libminc 2.4.07-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,288 kB
  • sloc: ansic: 57,268; cpp: 3,654; sh: 100; makefile: 23; ruby: 18
file content (60 lines) | stat: -rw-r--r-- 1,758 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ----------------------------- MNI Header -----------------------------------
@NAME       : 
@DESCRIPTION: minc exceptions
@COPYRIGHT  :
              Copyright 2006 Vladimir Fonov, McConnell Brain Imaging Centre, 
              Montreal Neurological Institute, McGill University.
              Permission to use, copy, modify, and distribute this
              software and its documentation for any purpose and without
              fee is hereby granted, provided that the above copyright
              notice appear in all copies.  The author and McGill University
              make no representations about the suitability of this
              software for any purpose.  It is provided "as is" without
              express or implied warranty.
---------------------------------------------------------------------------- */
#ifndef MINC_IO_EXCEPTIONS_H
#define MINC_IO_EXCEPTIONS_H

#define REPORT_ERROR(MSG) throw minc::generic_error(__FILE__,__LINE__,MSG)
#define CHECK_MINC_CALL(var) { if((var)<0) REPORT_ERROR("MINC CALL FAILED");}


namespace minc
{
  class generic_error
  {
  public:
    const char *_file;
    int _line;
    const char *_msg;
    int _code;
  public:

    generic_error (const char *file__, int line__, const char *msg__ = "Error", int code__ = 0):
    _file (file__), _line (line__), _msg (msg__), _code (code__)
    {
      //                    std::cerr<<"Exception created: "<<_file<<":"<<_line<<" "<<_msg<<std::endl;
    }

    const char *file (void) const
    {
      return _file;
    }

    const char *msg (void) const
    {
      return _msg;
    }

    int line (void) const
    {
      return _line;
    }

    int code (void) const
    {
      return _code;
    }
  };
} //minc
#endif //MINC_IO_EXCEPTIONS_H