Mercurial > pytave
annotate oct-py-error.h @ 423:6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
* oct-py-error.cc, oct-py-error.h (pytave::error_python_exception): New function
to generate an Octave error from an active Python error condition, based on
pytave::fetch_exception_message.
* oct-py-eval.cc (pytave::py_call_function, pytave::py_run_string_safe): Use it.
* oct-py-types.cc (pytave::make_py_dict): Likewise.
* oct-py-util.cc (pytave::py_objstore): Likewise.
* pycall.cc (Fpycall): Remove exception handling logic.
* pyeval.cc (Fpyeval): Likewise.
* pyexec.cc (Fpyexec): Likewise.
* exceptions.cc, exceptions.h: Delete.
* Makefile.am (COMMON_SOURCE_FILES, PYTAVE_HEADER_FILES): Remove them.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 04 May 2017 21:15:07 -0700 |
parents | 8247f298fd16 |
children |
rev | line source |
---|---|
422
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
1 /* |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
2 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
3 Copyright (C) 2017 Mike Miller |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
4 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
5 This file is part of Pytave. |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
6 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
7 Pytave is free software; you can redistribute it and/or modify it |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
10 option) any later version. |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
11 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
12 Pytave is distributed in the hope that it will be useful, but WITHOUT |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
15 for more details. |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
16 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
18 along with Pytave; see the file COPYING. If not, see |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
20 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
21 */ |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
22 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
23 #if ! defined (pytave_oct_py_error_h) |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
24 #define pytave_oct_py_error_h 1 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
25 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
26 #include <string> |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
27 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
28 #if defined (__GNUC__) |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
29 # define PYTAVE_ATTR_NORETURN __attribute__((__noreturn__)) |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
30 #else |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
31 # define PYTAVE_ATTR_NORETURN |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
32 #endif |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
33 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
34 namespace pytave |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
35 { |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
36 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
37 void |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
38 error_conversion_invalid_python_object (const std::string& to) |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
39 PYTAVE_ATTR_NORETURN; |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
40 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
41 void |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
42 error_conversion_mismatch_python_type (const std::string& to, |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
43 const std::string& must) |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
44 PYTAVE_ATTR_NORETURN; |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
45 |
423
6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
Mike Miller <mtmiller@octave.org>
parents:
422
diff
changeset
|
46 void |
6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
Mike Miller <mtmiller@octave.org>
parents:
422
diff
changeset
|
47 error_python_exception () |
6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
Mike Miller <mtmiller@octave.org>
parents:
422
diff
changeset
|
48 PYTAVE_ATTR_NORETURN; |
6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
Mike Miller <mtmiller@octave.org>
parents:
422
diff
changeset
|
49 |
422
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
50 } |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
51 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
52 #undef PYTAVE_ATTR_NORETURN |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
53 |
8247f298fd16
Raise Octave errors instead of exceptions for conversion errors
Mike Miller <mtmiller@octave.org>
parents:
diff
changeset
|
54 #endif |