[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Can I use an error handler that throws exceptions?
From: |
Jordi Gutierrez Hermoso |
Subject: |
[Help-gsl] Can I use an error handler that throws exceptions? |
Date: |
Sun, 12 Nov 2006 22:09:34 -0600 |
I wrote my error handler that throws exceptions instead of printing
error messages and calling abort(). I attach the relevant code in case
anyone wants to analyse it.
At any rate, my error handler does indeed throw exceptions, but is
there something I am not understanding about C/C++ or the GSL? I ask
because e.g. in the following code:
#include <iostream>
#include "error.h"
int main(int argc, char** argv){
using namespace std;
gsl_set_error_handler(&error_handling::errorHandler);
gsl_vector* thing = gsl_vector_alloc(10);
try{
gsl_vector_ptr(thing, 100);
}catch(...){
cout << "Exceptions work!" << endl; //Never gets here.
abort();
}
}
the exception isn't caught, and I end up with something that is worse
than the default GSL error handler, namely, also terminates abruptly
and gives even less information than the default. :-(
Why aren't my exceptions unwound back up to the code that throws them?
Thanks again,
- Jordi G. H.
error.cpp
Description: Text Data
error.h
Description: Text Data
- [Help-gsl] Can I use an error handler that throws exceptions?,
Jordi Gutierrez Hermoso <=