[Debian-astro-commits] [gyoto] 157/221: Python: catch Gyoto exceptions correctly
Thibaut Jean-Claude Paumard
thibaut at moszumanska.debian.org
Fri May 22 20:52:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
thibaut pushed a commit to branch master
in repository gyoto.
commit aa5b211a11b3729bee63f39512757faa69a16108
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date: Thu Dec 18 17:20:37 2014 +0100
Python: catch Gyoto exceptions correctly
---
python/gyoto.i | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/python/gyoto.i b/python/gyoto.i
index 6c50278..2de550d 100644
--- a/python/gyoto.i
+++ b/python/gyoto.i
@@ -49,13 +49,20 @@ Gyoto::SmartPointer<Gyoto::klass::Generic> pyGyoto ## klass (std::string const&s
#include "GyotoScreen.h"
using namespace Gyoto;
-void pyGyotoErrorHandler (const Gyoto::Error e) {
- std::cerr << "GYOTO error: "<<e<<std::endl;
- PyErr_SetString(PyExc_RuntimeError, e);
- return;
+%}
+
+%include "GyotoError.h"
+
+%exception {
+ try {
+ $function
+ }
+ catch (Gyoto::Error e) {
+ PyErr_SetString(PyExc_IndexError, e);
+ return NULL;
+ }
}
-%}
%include "std_string.i"
%include "std_vector.i"
@@ -65,10 +72,7 @@ void pyGyotoErrorHandler (const Gyoto::Error e) {
%array_class(double, array_double)
%include "numpy.i"
-%include "GyotoError.h"
-
%init {
- Gyoto::Error::setHandler(&pyGyotoErrorHandler);
Gyoto::Register::init();
import_array();
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git
More information about the Debian-astro-commits
mailing list