Changeset 95 for trunk


Ignore:
Timestamp:
11/12/04 13:37:20 (20 years ago)
Author:
mar637
Message:

added exception handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/python_SD.cc

    r83 r95  
    3333#include <boost/python.hpp>
    3434#include <boost/python/pyconversions.h>
     35#include <boost/python/exception_translator.hpp>
     36#include <casa/Exceptions.h>
    3537
    3638#include "python_SD.h"
    3739
     40namespace asap {
     41  namespace python {
     42void translate_ex(AipsError const& e)
     43{
     44  // Use the Python 'C' API to set up an exception object
     45  PyErr_SetString(PyExc_RuntimeError, e.what());
     46}
     47
     48  }
     49}
    3850using namespace boost::python;
    3951
    40 BOOST_PYTHON_MODULE(asap) {
     52BOOST_PYTHON_MODULE(_asap) {
    4153  asap::python::python_SDMemTable();
    4254  asap::python::python_SDReader();
    4355  asap::python::python_SDWriter();
    4456  asap::python::python_SDMath();
     57  asap::python::python_SDFitter();
     58
     59  register_exception_translator<AipsError>(&asap::python::translate_ex);
    4560
    4661  std_vector_to_tuple < int > ();
    47   from_python_sequence < std::vector < int >, 
     62  from_python_sequence < std::vector < int >,
    4863    variable_capacity_policy > ();
    4964  std_vector_to_tuple < float > ();
    50   from_python_sequence < std::vector < float >, 
     65  from_python_sequence < std::vector < float >,
    5166    variable_capacity_policy > ();
    5267  std_vector_to_tuple < double > ();
    53   from_python_sequence < std::vector < double >, 
     68  from_python_sequence < std::vector < double >,
    5469    variable_capacity_policy > ();
    5570  std_vector_to_tuple < std::string > ();
    56   from_python_sequence < std::vector < std::string >, 
     71  from_python_sequence < std::vector < std::string >,
    5772    variable_capacity_policy > ();
    5873  std_vector_to_tuple < bool> ();
    59   from_python_sequence < std::vector < bool >, 
     74  from_python_sequence < std::vector < bool >,
    6075    variable_capacity_policy > ();
    6176}
Note: See TracChangeset for help on using the changeset viewer.