Mercurial > pytave
annotate exceptions.h @ 375:d0a7f66393fc
Fix __py_class_name__ tests to work with Python 2
* __py_struct_from_dict__.cc: Fix __py_class_name__ tests to work with Python 2.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Fri, 26 Aug 2016 18:51:29 -0700 |
parents | 6fffa6219b2c |
children | 09a1acb81d8b |
rev | line source |
---|---|
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
1 /* |
139
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
2 |
150
a3dc9d24ae38
maint: Add myself to copyright notices
Mike Miller <mtmiller@octave.org>
parents:
146
diff
changeset
|
3 Copyright (C) 2015-2016 Mike Miller |
139
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
4 Copyright (C) 2008 David Grundberg, HÃ¥kan Fors Nilsson |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
5 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
6 This file is part of Pytave. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
7 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
8 Pytave is free software: you can redistribute it and/or modify it |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
11 option) any later version. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
12 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
13 Pytave is distributed in the hope that it will be useful, but WITHOUT |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
16 for more details. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
17 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
19 along with Pytave; see the file COPYING. If not, see |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
21 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
40
diff
changeset
|
22 */ |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
23 |
141
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
24 #if ! defined (pytave_exceptions_h) |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
25 #define pytave_exceptions_h |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
26 |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
27 #include <Python.h> |
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
28 #include <string> |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
29 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
30 namespace pytave |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
31 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
32 class pytave_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
33 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
34 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
35 static void translate_exception (const pytave_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
36 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
37 PyErr_SetString (PyExc_Exception, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
38 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
39 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
40 pytave_exception (const std::string& err) { error = err; }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
41 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
42 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
43 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
44 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
45 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
46 class octave_error_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
47 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
48 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
49 static bool init () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
50 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
51 excclass = PyErr_NewException (const_cast<char*> ("pytave.OctaveError"), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
52 PyExc_RuntimeError, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
53 return (excclass != 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
54 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
55 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
56 static void translate_exception (const octave_error_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
57 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
58 PyErr_SetString (excclass, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
59 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
60 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
61 static PyObject *excclass; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
62 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
63 octave_error_exception (const std::string& err) { error = err; }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
64 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
65 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
66 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
67 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
68 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
69 class octave_parse_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
70 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
71 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
72 static bool init () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
73 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
74 excclass = PyErr_NewException (const_cast<char*> ("pytave.ParseError"), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
75 PyExc_RuntimeError, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
76 return (excclass != 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
77 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
78 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
79 static void translate_exception (const octave_parse_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
80 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
81 PyErr_SetString (excclass, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
82 } |
36
ae4554656fa1
Added an eval function.
David Grundberg <individ@acc.umu.se>
parents:
26
diff
changeset
|
83 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
84 static PyObject *excclass; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
85 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
86 octave_parse_exception (const std::string& err) { error = err; }; |
36
ae4554656fa1
Added an eval function.
David Grundberg <individ@acc.umu.se>
parents:
26
diff
changeset
|
87 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
88 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
89 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
90 }; |
36
ae4554656fa1
Added an eval function.
David Grundberg <individ@acc.umu.se>
parents:
26
diff
changeset
|
91 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
92 class value_convert_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
93 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
94 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
95 static bool init () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
96 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
97 excclass = PyErr_NewException (const_cast<char*> ("pytave.ValueConvertError"), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
98 PyExc_TypeError, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
99 return (excclass != 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
100 }; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
101 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
102 static void translate_exception (const value_convert_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
103 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
104 PyErr_SetString (excclass, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
105 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
106 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
107 static PyObject *excclass; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
108 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
109 value_convert_exception (const std::string& err) { error = err; }; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
110 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
111 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
112 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
113 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
114 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
115 class object_convert_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
116 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
117 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
118 static bool init () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
119 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
120 excclass = PyErr_NewException (const_cast<char*> ("pytave.ObjectConvertError"), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
121 PyExc_TypeError, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
122 return (excclass != 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
123 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
124 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
125 static void translate_exception (const object_convert_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
126 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
127 PyErr_SetString (excclass, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
128 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
129 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
130 static PyObject *excclass; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
131 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
132 object_convert_exception (const std::string& err) { error = err; }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
133 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
134 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
135 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
136 }; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
137 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
138 class variable_name_exception |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
139 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
140 public: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
141 static bool init () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
142 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
143 excclass = PyErr_NewException (const_cast<char*> ("pytave.VarNameError"), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
144 PyExc_RuntimeError, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
145 return (excclass != 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
146 }; |
40
824354efaa1a
implement direct variable manipulation and local scoping
Jaroslav Hajek <highegg@gmail.com>
parents:
36
diff
changeset
|
147 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
148 static void translate_exception (const variable_name_exception& py_ex) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
149 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
150 PyErr_SetString (excclass, py_ex.error.c_str ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
151 } |
40
824354efaa1a
implement direct variable manipulation and local scoping
Jaroslav Hajek <highegg@gmail.com>
parents:
36
diff
changeset
|
152 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
153 static PyObject *excclass; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
154 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
155 variable_name_exception (const std::string& err) { error = err; }; |
40
824354efaa1a
implement direct variable manipulation and local scoping
Jaroslav Hajek <highegg@gmail.com>
parents:
36
diff
changeset
|
156 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
157 private: |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
158 std::string error; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
141
diff
changeset
|
159 }; |
171
b8560f97e9bf
Wrap custom exception initialization in a function
Mike Miller <mtmiller@octave.org>
parents:
150
diff
changeset
|
160 |
b8560f97e9bf
Wrap custom exception initialization in a function
Mike Miller <mtmiller@octave.org>
parents:
150
diff
changeset
|
161 bool init_exceptions (void); |
231
6fffa6219b2c
Properly extract exception text from Python (fixes issue #24)
Abhinav Tripathi <genuinelucifer@gmail.com>
parents:
171
diff
changeset
|
162 std::string fetch_exception_message (void); |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
163 } |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
164 |
141
4e5a620758fc
Use consistent Octave style for header files
Mike Miller <mtmiller@octave.org>
parents:
139
diff
changeset
|
165 #endif |