Commit e34ad9cd9503c1b1d3393a6d527abff15cc94be8

Authored by Jürgen Knödlseder
1 parent 1f9623b4

Add generic catch for GammaLib exceptions.

There were some problems on Mac OS X 10.7 with catching of GammaLib exceptions (see bugs #681, #680, #626). These could be solved by adding a generic catch of @GExceptionHandler@ to the Python interface exception handler.

Some of the old specific exceptions have also been removed.
Showing 1 changed file with 9 additions and 10 deletions
pyext/GException.i
1 1 /***************************************************************************
2   - * GException.i - exception handler *
  2 + * GException.i - exception handler *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2011 by Jurgen Knodlseder *
  4 + * copyright (C) 2008-2012 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -18,6 +18,11 @@
18 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 19 * *
20 20 ***************************************************************************/
  21 +/**
  22 + * @file GException.i
  23 + * @brief Exception handler for Python interface
  24 + * @author Juergen Knoedlseder
  25 + */
21 26 %{
22 27 /* Put headers and other declarations here */
23 28 #include "GException.hpp"
... ... @@ -28,17 +33,11 @@
28 33 try {
29 34 $action
30 35 }
31   - catch (const GException::mem_alloc& e) {
32   - SWIG_exception(SWIG_MemoryError, e.what());
33   - }
34   - catch (const GException::empty& e) {
35   - SWIG_exception(SWIG_ValueError, e.what());
36   - }
37 36 catch (const GException::out_of_range& e) {
38 37 SWIG_exception(SWIG_IndexError, e.what());
39 38 }
40   - catch (const GException::fits_invalid_type& e) {
41   - SWIG_exception(SWIG_ValueError, e.what());
  39 + catch (const GExceptionHandler& e) {
  40 + SWIG_exception(SWIG_RuntimeError, e.what());
42 41 }
43 42 catch (const std::exception& e) {
44 43 SWIG_exception(SWIG_RuntimeError, e.what());
... ...