diff options
author | schnetter <> | 2004-06-26 13:08:00 +0000 |
---|---|---|
committer | schnetter <> | 2004-06-26 13:08:00 +0000 |
commit | dd92d5d080ec6638fbeec79e580243ef6af1e534 (patch) | |
tree | 5b1dbc1483c046686a3976642da36ed4a0681697 /Carpet/CarpetLib/src | |
parent | f361872363872f273b94da60afc4a454f9cf9edf (diff) |
Throw an input_error instead of using assert when there is wrong input.
darcs-hash:20040626130809-07bb3-14d132fa6dd6c3fbbba9582f4e7f0f2e78dc9586.gz
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r-- | Carpet/CarpetLib/src/bbox.cc | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc index 4136ac408..9269e042d 100644 --- a/Carpet/CarpetLib/src/bbox.cc +++ b/Carpet/CarpetLib/src/bbox.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.25 2004/05/21 18:13:41 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.26 2004/06/26 15:08:09 schnetter Exp $ #include <assert.h> @@ -222,17 +222,32 @@ typename bbox<T,D>::iterator bbox<T,D>::end () const { // Input template<class T,int D> void bbox<T,D>::input (istream& is) { - skipws (is); - consume (is, '('); - is >> _lower; - skipws (is); - consume (is, ':'); - is >> _upper; - skipws (is); - consume (is, ':'); - is >> _stride; - skipws (is); - consume (is, ')'); + try { + skipws (is); + consume (is, '('); + is >> _lower; + skipws (is); + consume (is, ':'); + is >> _upper; + skipws (is); + consume (is, ':'); + is >> _stride; + skipws (is); + consume (is, ')'); + } catch (input_error &err) { + cout << "Input error while reading a bbox" << endl; + throw err; + } + if (any(_stride<=T(0))) { + cout << "While reading the bbox " << *this << ":" << endl + << " The stride is not positive." << endl; + throw input_error(); + } + if (any((_upper-_lower)%_stride != T(0))) { + cout << "While reading the bbox " << *this << ":" << endl + << " The stride does not evenly divide the extent." << endl; + throw input_error(); + } assert (all(_stride>T(0))); assert (all((_upper-_lower)%_stride == T(0))); } |