BUG: sparse/sparsetools: catch c++ exceptions

These can appear e.g. in out-of-memory situations or from other causes
inside STL.
MAINT: sparse: Tweak the definition of test_throw_error to avoid multiple instantations.
GEN: sparse: regenerate sparsetools
Merge pull request #3215 from pv/swig-badalloc

 BUG: sparse/sparsetools: catch c++ exceptions