From cd2af06d331415235c530640ec2ed637f8f1abc8 Mon Sep 17 00:00:00 2001 From: Alan Grossfield Date: Sat, 8 Aug 2020 18:00:05 -0400 Subject: [PATCH] catch parser errors in python when using parseRangeList --- src/catch_it.i | 1 + src/exceptions.i | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/catch_it.i b/src/catch_it.i index 70bb1e54c..73707c511 100644 --- a/src/catch_it.i +++ b/src/catch_it.i @@ -29,6 +29,7 @@ createTrajectory; std::logic_error)\ selectAtoms; +%catches(loos::ParseError) parseRangeList; // amber %catches(loos::FileOpenError, loos::FileReadErrorWithLine, loos::LOOSError) Amber::Amber; diff --git a/src/exceptions.i b/src/exceptions.i index 27f92fa69..3b4d20e0e 100644 --- a/src/exceptions.i +++ b/src/exceptions.i @@ -1,5 +1,5 @@ %{ - + #include #include @@ -39,7 +39,11 @@ const char* __str__() { std::string s = self->what(); return(s.c_str()); } } + %extend loos::FileWriteError { const char* __str__() { std::string s = self->what(); return(s.c_str()); } } +%extend loos::ParseError { + const char* __str__() { std::string s = self->what(); return(s.c_str()); } +}