diff --git a/modules/base/src/generic_property.hh b/modules/base/src/generic_property.hh index a7ea0782510763ec3849a4f28fb880a60afb2d99..5220d7741d2df6aff1356dec25603ac41ff036eb 100644 --- a/modules/base/src/generic_property.hh +++ b/modules/base/src/generic_property.hh @@ -28,7 +28,6 @@ setter and getter methods for String, Real, int and bool mapping */ -#include <exception> #include <sstream> #include <map> #include <vector> @@ -36,19 +35,15 @@ #include <ost/module_config.hh> #include <ost/invalid_handle.hh> +#include <ost/message.hh> namespace ost { -struct TEMPLATE_EXPORT GenericPropError: public std::exception +struct DLLEXPORT GenericPropError: public Error { GenericPropError(const String& m): - m_(m) + Error(m) {} - virtual ~GenericPropError() throw() {} - virtual const char* what() const throw() { - return m_.c_str(); - } - String m_; }; typedef boost::variant<String, Real, int, bool> GenericPropValue; diff --git a/modules/base/src/message.cc b/modules/base/src/message.cc index 6fc3e6e31dce299cf20b937a8b02cf19f1031c9d..572480206588eaf96cbe29e7f748d8c68c8952d2 100644 --- a/modules/base/src/message.cc +++ b/modules/base/src/message.cc @@ -20,7 +20,7 @@ /* messages and logs - Authors: Ansgar Philippsen, Andteas Schenk + Authors: Ansgar Philippsen, Andreas Schenk */ #include "message.hh" @@ -28,17 +28,7 @@ namespace ost { Error::Error(const String& m): - mesg_(m) + std::runtime_error(m) {} -Error::~Error() throw() -{ } - -const char* Error::what() const throw() -{ - return mesg_.c_str(); -} - -} - diff --git a/modules/base/src/message.hh b/modules/base/src/message.hh index 6a98dbc2bdc3a7983d3654b2c3759d2d6b3eecbc..5dd148264d3f6a867be593fcd0a5725dde377b31 100644 --- a/modules/base/src/message.hh +++ b/modules/base/src/message.hh @@ -20,25 +20,21 @@ /* messages and logs - Authors: Ansgar Philippsen, Andteas Schenk + Authors: Ansgar Philippsen, Andreas Schenk */ #ifndef OST_MESSAGE_HH #define OST_MESSAGE_HH -#include <exception> +#include <stdexcept> #include <ost/module_config.hh> namespace ost { -class DLLEXPORT Error: virtual public std::exception { +class DLLEXPORT Error: public std::runtime_error { public: Error(const String& m); - ~Error() throw(); - virtual const char* what() const throw(); -protected: - String mesg_; }; } // namespace diff --git a/modules/base/src/ptr_observer.hh b/modules/base/src/ptr_observer.hh index a5f9cfbb10799cbb2ff8df11cd80a678db36f174..4b98e1fd52b972deea02b6207dcb0f1bfedb48bc 100644 --- a/modules/base/src/ptr_observer.hh +++ b/modules/base/src/ptr_observer.hh @@ -29,7 +29,7 @@ Author: Ansgar Philippsen */ -class DLLEXPORT_OST_BASE InvalidatedPointer: public ost::Error { +class DLLEXPORT InvalidatedPointer: public ost::Error { public: InvalidatedPointer(): ost::Error("access attempt on invalidated Pointer") diff --git a/modules/conop/pymod/export_compound.cc b/modules/conop/pymod/export_compound.cc index 05f27a82e01dcb1f969a1c43a44ce875490cc148..6b8196e6768a608745c9c83608a7ddffc6ef50d3 100644 --- a/modules/conop/pymod/export_compound.cc +++ b/modules/conop/pymod/export_compound.cc @@ -21,6 +21,7 @@ #include <boost/python/suite/indexing/vector_indexing_suite.hpp> using namespace boost::python; +#include <ost/message.hh> #include <ost/conop/compound.hh> #include <ost/conop/compound_lib.hh> using namespace ost::mol; @@ -44,7 +45,7 @@ Compound::Dialect tr_dialect(const String& dialect) } std::stringstream ss; ss << "unknown compound dialect '" << dialect << "'"; - throw std::runtime_error(ss.str()); + throw ost::Error(ss.str()); } void set_dialect(CompoundPtr compound, const String& dialect) diff --git a/modules/conop/src/conop.cc b/modules/conop/src/conop.cc index f72956f1a2f732a5734ddd1a8d20bec46e5cc91f..e48b3444e16c4ac7bf1ba5ef70ea28ff8341f93a 100644 --- a/modules/conop/src/conop.cc +++ b/modules/conop/src/conop.cc @@ -16,6 +16,7 @@ // along with this library; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ +#include <ost/message.hh> #include <ost/mol/mol.hh> #include <ost/log.hh> @@ -161,7 +162,7 @@ void Conopology::SetDefaultBuilder(const String& default_name) { if (builder) builder_map_["DEFAULT"]=builder; else - throw std::runtime_error("trying to set unknown builder '"+ + throw ost::Error("trying to set unknown builder '"+ default_name+"' as the default"); } diff --git a/modules/geom/src/exc.hh b/modules/geom/src/exc.hh index 67eda2278e8ec380aa154dc16552e04b70a782cc..0c4390030e9d6d3c520a9876722e8ce564be4134 100644 --- a/modules/geom/src/exc.hh +++ b/modules/geom/src/exc.hh @@ -33,19 +33,19 @@ namespace geom { code may choose to catch exceptions from the geom library undifferentiatedly */ -class DLLEXPORT_OST_GEOM GeomException: public std::runtime_error { +class DLLEXPORT GeomException: public std::runtime_error { public: GeomException(const String& m): std::runtime_error(m) {} }; -class DLLEXPORT_OST_GEOM DivideByZeroException: public GeomException { +class DLLEXPORT DivideByZeroException: public GeomException { public: DivideByZeroException(const String& m="Divide By Zero"): GeomException(m) {} }; -class DLLEXPORT_OST_GEOM OutOfRangeException: public GeomException { +class DLLEXPORT OutOfRangeException: public GeomException { public: OutOfRangeException(const String& m="Out Of Range"): GeomException(m) {} diff --git a/modules/geom/src/exception.hh b/modules/geom/src/exception.hh deleted file mode 100644 index dded875655957f126b6dee28e0ff66f04c4168e4..0000000000000000000000000000000000000000 --- a/modules/geom/src/exception.hh +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 by the OpenStructure authors -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License as published by the Free -// Software Foundation; either version 3.0 of the License, or (at your option) -// any later version. -// This library is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -// details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this library; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ -#ifndef GEOM_EXCEPTION_HH -#define GEOM_EXCEPTION_HH - -#include <string> -#include <ost/message.hh> -#include "module_config.hh" - -namespace geom { - -class DLLEXPORT_OST_GEOM GeomException: public Error -{ -public: - GeomException(const String& m): - Error(m) {} - -}; - -} - diff --git a/modules/geom/src/vecmat3_op.cc b/modules/geom/src/vecmat3_op.cc index 50b5b612e939d66e6d8119ddced416ff87e52f99..8a1debee816113fc87d196379b6e0230a241238d 100644 --- a/modules/geom/src/vecmat3_op.cc +++ b/modules/geom/src/vecmat3_op.cc @@ -196,7 +196,7 @@ Real DihedralAngle(const Vec3& p1, const Vec3& p2, const Vec3& p3, Real MinDistance(const Vec3List& l1, const Vec3List& l2) { // returns the minimal distance between two sets of points (Vec3List) - if (l1.size()==0 || l2.size()==0){throw std::runtime_error("cannot calculate minimal distance: empty Vec3List");} + if (l1.size()==0 || l2.size()==0){throw GeomException("cannot calculate minimal distance: empty Vec3List");} Real min=Length2(*l1.begin()-*l2.begin()); Real d; for (Vec3List::const_iterator p1=l1.begin(),e1=l1.end(); p1!=e1; p1++) { @@ -212,7 +212,7 @@ Real MinDistanceWithPBC(const Vec3List& l1, const Vec3List& l2, Vec3& basis_vec) { // returns the minimal distance between two sets of points (Vec3List) // given the periodic boundary condition along x,y,z given in the basis_vec - if (l1.size()==0 || l2.size()==0){throw std::runtime_error("cannot calculate minimal distance: empty Vec3List");} + if (l1.size()==0 || l2.size()==0){throw GeomException("cannot calculate minimal distance: empty Vec3List");} Real min=Length2(*l1.begin()-*l2.begin()); Real d; Vec3 v; diff --git a/modules/geom/tests/test_op3.cc b/modules/geom/tests/test_op3.cc index de7e74843e536b2b635d111752e1142c6cd7dcb2..1d4660b4e8cf92d2f6506bd900bad16aaf480dec 100644 --- a/modules/geom/tests/test_op3.cc +++ b/modules/geom/tests/test_op3.cc @@ -52,11 +52,11 @@ BOOST_AUTO_TEST_CASE(vecmat_mult3) BOOST_AUTO_TEST_CASE(vec3list_op) { Vec3List l1,l2; - BOOST_CHECK_THROW(MinDistance(l1,l2),std::runtime_error); + BOOST_CHECK_THROW(MinDistance(l1,l2),GeomException); l1.push_back(Vec3(0.0,0.0,0.0)); l1.push_back(Vec3(1.0,0.0,0.0)); - BOOST_CHECK_THROW(MinDistance(l1,l2),std::runtime_error); - BOOST_CHECK_THROW(MinDistance(l2,l1),std::runtime_error); + BOOST_CHECK_THROW(MinDistance(l1,l2),GeomException); + BOOST_CHECK_THROW(MinDistance(l2,l1),GeomException); l2.push_back(Vec3(4.0,4.0,0.0)); l2.push_back(Vec3(2.0,4.0,5.0)); l2.push_back(Vec3(0.0,3.0,6.0)); diff --git a/modules/gfx/pymod/export_gradient.cc b/modules/gfx/pymod/export_gradient.cc index 4832495381ef699dbf871bfc9eaa3449ebe622f9..03eeb5401314968c1dba50967224846c11aa7ad7 100644 --- a/modules/gfx/pymod/export_gradient.cc +++ b/modules/gfx/pymod/export_gradient.cc @@ -38,7 +38,7 @@ namespace { for(int i=0;i<len(keys);++i) { extract<float> fex(keys[i]); if(!fex.check()) { - throw std::runtime_error("expected floats as keys"); + throw Error("expected floats as keys"); } float mark = fex(); Color col; @@ -50,12 +50,12 @@ namespace { } else { // try simple sequence if(len(val)!=3) { - throw std::runtime_error("expected values of gfx.Color or float triplets"); + throw Error("expected values of gfx.Color or float triplets"); } try { col=gfx::Color(extract<float>(val[0]),extract<float>(val[1]),extract<float>(val[2])); } catch (...) { - throw std::runtime_error("expected values of gfx.Color or float triplets"); + throw Error("expected values of gfx.Color or float triplets"); } } grad->SetColorAt(mark,col); @@ -78,12 +78,12 @@ namespace { } else { // try simple sequence if(len(val)!=3) { - throw std::runtime_error("expected values of gfx.Color or float triplets"); + throw Error("expected values of gfx.Color or float triplets"); } try { col=gfx::RGB(extract<float>(val[0]),extract<float>(val[1]),extract<float>(val[2])); } catch (...) { - throw std::runtime_error("expected values of gfx.Color float triplets"); + throw Error("expected values of gfx.Color float triplets"); } } grad->SetColorAt(mark,col); diff --git a/modules/gfx/pymod/export_primlist.cc b/modules/gfx/pymod/export_primlist.cc index 0d6d2bb1623466d3aa81a6c6758fcf9b931f0072..8cdaf32303ae80ff65d787642d2e9a01b8d5bc0d 100644 --- a/modules/gfx/pymod/export_primlist.cc +++ b/modules/gfx/pymod/export_primlist.cc @@ -21,6 +21,7 @@ using namespace boost::python; #include <boost/shared_ptr.hpp> +#include <ost/message.hh> #include <ost/gfx/prim_list.hh> using namespace ost; using namespace ost::gfx; @@ -34,18 +35,18 @@ namespace { { #if OST_NUMPY_SUPPORT_ENABLED if(!PyArray_Check(ova.ptr())) { - throw std::runtime_error("ova is not a numpy array"); + throw Error("ova is not a numpy array"); } PyArrayObject* va=reinterpret_cast<PyArrayObject*>(ova.ptr()); if(!PyArray_ISCONTIGUOUS(va)) { - throw std::runtime_error("expected vertex array to be contiguous"); + throw Error("expected vertex array to be contiguous"); } if(!PyArray_TYPE(va)==NPY_FLOAT) { - throw std::runtime_error("expected vertex array to be of dtype=float32"); + throw Error("expected vertex array to be of dtype=float32"); } size_t v_size=PyArray_SIZE(va); if(v_size%3!=0) { - throw std::runtime_error("expected vertex array size to be divisible by 3"); + throw Error("expected vertex array size to be divisible by 3"); } size_t v_count=v_size/3; float* vp=reinterpret_cast<float*>(PyArray_DATA(va)); @@ -53,52 +54,52 @@ namespace { float* cp=0; if(ona!=object()) { if(!PyArray_Check(ona.ptr())) { - throw std::runtime_error("ona is not a numpy array"); + throw Error("ona is not a numpy array"); } PyArrayObject* na=reinterpret_cast<PyArrayObject*>(ona.ptr()); if(!PyArray_ISCONTIGUOUS(na)) { - throw std::runtime_error("expected normal array to be contiguous"); + throw Error("expected normal array to be contiguous"); } if(!PyArray_TYPE(na)==NPY_FLOAT) { - throw std::runtime_error("expected normal array to be of dtype=float32"); + throw Error("expected normal array to be of dtype=float32"); } if((size_t)PyArray_SIZE(na)!=v_size) { - throw std::runtime_error("expected normal array size to match vertex array size"); + throw Error("expected normal array size to match vertex array size"); } np=reinterpret_cast<float*>(PyArray_DATA(na)); } if(oca!=object()) { if(!PyArray_Check(oca.ptr())) { - throw std::runtime_error("oca is not a numpy array"); + throw Error("oca is not a numpy array"); } PyArrayObject* ca=reinterpret_cast<PyArrayObject*>(oca.ptr()); if(!PyArray_ISCONTIGUOUS(ca)) { - throw std::runtime_error("expected color array to be contiguous"); + throw Error("expected color array to be contiguous"); } if(!PyArray_TYPE(ca)==NPY_FLOAT) { - throw std::runtime_error("expected color array to be of dtype=float32"); + throw Error("expected color array to be of dtype=float32"); } if((size_t)PyArray_SIZE(ca)!=v_count*4) { - throw std::runtime_error("expected color array size to equal vertex-count x 4"); + throw Error("expected color array size to equal vertex-count x 4"); } cp=reinterpret_cast<float*>(PyArray_DATA(ca)); } if(!PyArray_Check(oia.ptr())) { - throw std::runtime_error("oia is not a numpy array"); + throw Error("oia is not a numpy array"); } PyArrayObject* ia=reinterpret_cast<PyArrayObject*>(oia.ptr()); if(!PyArray_ISCONTIGUOUS(ia)) { - throw std::runtime_error("expected vertex array to be contiguous"); + throw Error("expected vertex array to be contiguous"); } if(!PyArray_TYPE(ia)==NPY_UINT) { - throw std::runtime_error("expected vertex array to be of dtype=uint32"); + throw Error("expected vertex array to be of dtype=uint32"); } size_t i_size=PyArray_SIZE(ia); unsigned int* ip=reinterpret_cast<unsigned int*>(PyArray_DATA(ia)); p.AddMesh(vp,np,cp,v_count,ip,i_size/3); #else - throw std::runtime_error("AddMesh requires compiled-in numpy support"); + throw Error("AddMesh requires compiled-in numpy support"); #endif } } diff --git a/modules/img/alg/src/histogram.hh b/modules/img/alg/src/histogram.hh index e6a22592acb24e4dea120b8ca6a20fa286ea4184..820744d31b01ace41437c9d0293a24f086291dfa 100644 --- a/modules/img/alg/src/histogram.hh +++ b/modules/img/alg/src/histogram.hh @@ -35,8 +35,7 @@ namespace ost { namespace img { namespace alg { class DLLEXPORT HistogramError: public Error { public: - virtual ~HistogramError() throw() {} // required for typeinfo visibility - HistogramError(const String& s): + HistogramError(const String& s): Error(String("A histogram error occured: ") + s) {} }; diff --git a/modules/img/alg/tests/test_histogram.cc b/modules/img/alg/tests/test_histogram.cc index 98f323a21c927ec4da09da9dd935699f20bb2042..c5382ce88745c390ebd3a988feeeb4b8b076f202 100644 --- a/modules/img/alg/tests/test_histogram.cc +++ b/modules/img/alg/tests/test_histogram.cc @@ -61,6 +61,13 @@ void test() msg << " expected bins[" << k << "] == 1 but got " << bins[k]; BOOST_CHECK_MESSAGE(bins[k]==1,msg.str()); } + try { + BOOST_CHECK_THROW(Histogram(1,0.0,1.0),HistogramError); + }catch(...){ + BOOST_ERROR( "Failed to catch HisotgramException." ); + } + + } } // namespace diff --git a/modules/img/base/pymod/export_image_handle.cc b/modules/img/base/pymod/export_image_handle.cc index ff8197f311a635ea748e9ab034b9c1c43f141fd5..24aace26cb7b1a4d4945296e592c6ee3cd27d8f5 100644 --- a/modules/img/base/pymod/export_image_handle.cc +++ b/modules/img/base/pymod/export_image_handle.cc @@ -25,6 +25,7 @@ #include <boost/python.hpp> using namespace boost::python; +#include <ost/message.hh> #include <ost/img/algorithm.hh> #include <ost/img/image.hh> #include <ost/img/function.hh> @@ -94,7 +95,7 @@ img::Point tuple_to_point(size_t dim, tuple t) { size_t tuple_len=len(t); if (tuple_len!=dim) { - throw std::runtime_error("length of tuple and image dimension must match"); + throw ost::Error("length of tuple and image dimension must match"); } img::Point p; for (size_t i=0; i<tuple_len; ++i) { @@ -120,7 +121,7 @@ object ih_get_item_a(ConstImageHandle ih, tuple t) object ih_get_item_c(ConstImageHandle ih, int x) { if (ih.GetSize().GetDim()!=1) { - throw std::runtime_error("Can't address point of multi-dimensional image with scalar"); + throw ost::Error("Can't address point of multi-dimensional image with scalar"); } return ih_get_item(ih, img::Point(x, 0, 0)); } @@ -152,7 +153,7 @@ void ih_set_item_b(ImageHandle ih, img::Point p, object value) void ih_set_item_c(ImageHandle ih, int x, object value) { if (ih.GetSize().GetDim()!=1) { - throw std::runtime_error("Can't address point of multi-dimensional image with scalar"); + throw ost::Error("Can't address point of multi-dimensional image with scalar"); } ih_set_item(ih, img::Point(x, 0, 0), value); } diff --git a/modules/img/base/src/point.cc b/modules/img/base/src/point.cc index 80ac131f97ee3fb198027455c367dd16109dc4d5..3cadd17b077843974d54af42a7bce5610ccbaf52 100644 --- a/modules/img/base/src/point.cc +++ b/modules/img/base/src/point.cc @@ -87,7 +87,7 @@ Point::Point(const Vec4& v): data_() { if(std::abs(v[3])<1e-100) { - throw std::range_error("4th element of Vec4 is too close to zero for normalization"); + throw geom::OutOfRangeException("4th element of Vec4 is too close to zero for normalization"); } else { Real sf = 1.0/v[3]; data_[0]=static_cast<int>(round(v[0]*sf)); @@ -245,7 +245,7 @@ int& Point::operator[](unsigned int index) int Point::operator[](unsigned int index) const { - if(index>2) throw std::range_error("Point index out of range"); + if(index>2) throw geom::OutOfRangeException("Point index out of range"); return data_[index]; } diff --git a/modules/img/base/src/size.cc b/modules/img/base/src/size.cc index e8c0ed1b86f9c8f6a00e85d9fe5e2f24995c9cc1..97e1fa46001e1365d21fb3b9e2ed67d9c49f6252 100644 --- a/modules/img/base/src/size.cc +++ b/modules/img/base/src/size.cc @@ -108,7 +108,7 @@ unsigned int& Size::operator[](unsigned int index) if(index==0) return w_; else if(index==1) return h_; else if(index==2) return d_; - else throw std::range_error("Size index out of range"); + else throw geom::OutOfRangeException("Size index out of range"); } unsigned int Size::operator[](unsigned int index) const @@ -116,7 +116,7 @@ unsigned int Size::operator[](unsigned int index) const if(index==0) return w_; else if(index==1) return h_; else if(index==2) return d_; - else throw std::range_error("Size index out of range"); + else throw geom::OutOfRangeException("Size index out of range"); } bool Size::operator==(const Size& s) const diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc index b17b22ea8042231aab785d6bf960f3d8146e018b..eb9c852b521990d2195cabc379a82b5d4673dd31 100644 --- a/modules/io/tests/test_mmcif_reader.cc +++ b/modules/io/tests/test_mmcif_reader.cc @@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE(mmcif_unknown_entity_type) BOOST_MESSAGE(" unknown type..."); columns.pop_back(); columns.push_back(StringRef("foo", 3)); - BOOST_CHECK_THROW(tmmcif_p.ParseEntity(columns), std::runtime_error); + BOOST_CHECK_THROW(tmmcif_p.ParseEntity(columns), Error); BOOST_MESSAGE(" done."); BOOST_MESSAGE(" done."); diff --git a/modules/mol/alg/src/construct_cbeta.cc b/modules/mol/alg/src/construct_cbeta.cc index 19cdec41dafd5ea4e3a1369d6bd21520e464c1cf..5eaf96046ca42eb475992972b2d7b88c31742a25 100644 --- a/modules/mol/alg/src/construct_cbeta.cc +++ b/modules/mol/alg/src/construct_cbeta.cc @@ -1,5 +1,6 @@ #include <cmath> +#include <ost/message.hh> #include <ost/mol/mol.hh> #include <ost/log.hh> #include "construct_cbeta.hh" @@ -83,7 +84,7 @@ geom::Vec3 CBetaPosition(const ResidueHandle& residue, Real bond_length) std::stringstream ss; ss << "residue " << residue.GetQualifiedName() << "doesn't have enough backbone atoms to reconstruct CBeta position"; - throw std::runtime_error(ss.str()); + throw ost::Error(ss.str()); } return CBetaPosition(n.GetPos(), ca.GetPos(), c.GetPos(), bond_length); } diff --git a/modules/mol/alg/src/entity_to_density.cc b/modules/mol/alg/src/entity_to_density.cc index 6a15ac44fc68fd179f19b5f1d9405b259ecc3923..a01bd49c173f2f9c6ad2a76ac7c0465df49edfe2 100644 --- a/modules/mol/alg/src/entity_to_density.cc +++ b/modules/mol/alg/src/entity_to_density.cc @@ -378,9 +378,9 @@ void EntityToDensityScattering(const mol::EntityView& entity_view, bool clear_map_flag, Real source_wavelength) { - if(falloff_start<=0.0) throw std::runtime_error("Invalid falloff start"); + if(falloff_start<=0.0) throw ost::Error("Invalid falloff start"); if(falloff_end<=0.0 || falloff_end>falloff_start) - throw std::runtime_error("Invalid falloff end"); + throw ost::Error("Invalid falloff end"); geom ::Vec3 rs_sampl = map.GetSpatialSampling(); geom ::Vec3 abs_orig = map.GetAbsoluteOrigin(); @@ -420,7 +420,7 @@ void EntityToDensityRosetta(const mol::EntityView& entity_view, Real source_wavelength) { - if(resolution <=0.0) throw std::runtime_error("Invalid resolution"); + if(resolution <=0.0) throw ost::Error("Invalid resolution"); if (clear_map_flag==true) { img::MapHandle mm=img::CreateImage(img::Extent(img::Point(0,0), map.GetSize())); diff --git a/modules/mol/alg/src/superpose_frames.cc b/modules/mol/alg/src/superpose_frames.cc index 85514d6d73a51ea060af6214dd9a748ca336f684..f5cbba61073416b7c47dd05393c9104f4ee0b0b2 100644 --- a/modules/mol/alg/src/superpose_frames.cc +++ b/modules/mol/alg/src/superpose_frames.cc @@ -21,6 +21,7 @@ #include <Eigen/Array> #include <Eigen/SVD> #include <Eigen/LU> +#include <ost/message.hh> #include <ost/mol/mol.hh> #include <ost/mol/alg/superpose_frames.hh> @@ -196,7 +197,7 @@ CoordGroupHandle SuperposeFrames(CoordGroupHandle& cg, EntityView& sel, //This function superposes the frames of a CoordGroup (cg) with indices between begin and end, //using a selection of atoms (sel), onto an EntityView (ref_view). if (!ref_view.IsValid()){ - throw std::runtime_error("Invalid reference view"); + throw ost::Error("Invalid reference view"); } int real_end=end==-1 ? cg.GetFrameCount() : end; CoordFramePtr ref_frame; @@ -215,7 +216,7 @@ CoordGroupHandle SuperposeFrames(CoordGroupHandle& cg, EntityView& sel, } } if (int(indices.size())!=ref_view.GetAtomCount()){ - throw std::runtime_error("atom counts of the two views are not equal"); + throw ost::Error("atom counts of the two views are not equal"); } mol::AtomHandleList alist(cg.GetEntity().GetAtomList()); std::sort(alist.begin(), alist.end(),less_index); diff --git a/modules/mol/alg/src/svd_superpose.cc b/modules/mol/alg/src/svd_superpose.cc index 22fa34c1d8c48a9aa370d006a3ab68a5276af091..f6b0a353d23c8ca6db39175082a745960cd570a6 100644 --- a/modules/mol/alg/src/svd_superpose.cc +++ b/modules/mol/alg/src/svd_superpose.cc @@ -55,7 +55,7 @@ Real CalculateRMSD(const mol::EntityView& ev1, int counta=ev1.GetAtomCount(); int countb=ev2.GetAtomCount(); if (counta!=countb){ - throw std::runtime_error("atom counts of the two views are not equal"); + throw Error("atom counts of the two views are not equal"); } eht=ev1.GetHandle(); int natoms=ev1.GetAtomCount(); @@ -308,10 +308,10 @@ SuperpositionResult SuperposeAtoms(const mol::AtomViewList& atoms1, int counta=static_cast<int>(atoms1.size()); int countb=static_cast<int>(atoms2.size()); if (counta!=countb){ - throw std::runtime_error("atom counts do not match"); + throw Error("atom counts do not match"); } if ((counta<3)){ - throw std::runtime_error("at least 3 atoms are required"); + throw Error("at least 3 atoms are required"); } SuperposerSVD sp(counta, true); @@ -333,10 +333,10 @@ SuperpositionResult SuperposeSVD(const mol::EntityView& ev1, int counta=ev1.GetAtomCount(); int countb=ev2.GetAtomCount(); if (counta!=countb){ - throw std::runtime_error("atom counts of the two views are not equal"); + throw Error("atom counts of the two views are not equal"); } if ((counta<3)){ - throw std::runtime_error("atom counts of any view must be larger or " + throw Error("atom counts of any view must be larger or " "equal 3"); } int nrows=counta; @@ -358,10 +358,10 @@ SuperpositionResult SuperposeSVD(const std::vector<geom::Vec3>& pl1, const std::vector<geom::Vec3>& pl2) { if (pl1.size()!=pl2.size()){ - throw std::runtime_error("pointlist lengths not equal"); + throw Error("pointlist lengths not equal"); } if ((pl1.size()<3)){ - throw std::runtime_error("three or more points required"); + throw Error("three or more points required"); } SuperposerSVD sp(pl1.size(), true); SuperpositionResult res=sp.Run(pl1, pl2); diff --git a/modules/mol/alg/src/trajectory_analysis.cc b/modules/mol/alg/src/trajectory_analysis.cc index 5adf3c6eb1bc584522abcfec8725ebe2651fe213..a4ce2026b2248fd2ea8144c170e13b2cca46198f 100644 --- a/modules/mol/alg/src/trajectory_analysis.cc +++ b/modules/mol/alg/src/trajectory_analysis.cc @@ -138,7 +138,7 @@ std::vector<Real> AnalyzeRMSD(const CoordGroupHandle& traj, const EntityView& re int count_ref=reference_view.GetAtomCount(); int count_sele=sele_view.GetAtomCount(); if (count_ref!=count_sele){ - throw std::runtime_error("atom counts of the two views are not equal"); + throw Error("atom counts of the two views are not equal"); } std::vector<Real> rmsd; rmsd.reserve(ceil(traj.GetFrameCount()/float(stride))); @@ -160,10 +160,10 @@ std::vector<Real> AnalyzeMinDistance(const CoordGroupHandle& traj, const Entity { CheckHandleValidity(traj); if (view1.GetAtomCount()==0){ - throw std::runtime_error("first EntityView is empty"); + throw Error("first EntityView is empty"); } if (view2.GetAtomCount()==0){ - throw std::runtime_error("second EntityView is empty"); + throw Error("second EntityView is empty"); } std::vector<Real> dist; dist.reserve(ceil(traj.GetFrameCount()/float(stride))); @@ -184,10 +184,10 @@ std::vector<Real> AnalyzeMinDistanceBetwCenterOfMassAndView(const CoordGroupHand { CheckHandleValidity(traj); if (view_cm.GetAtomCount()==0){ - throw std::runtime_error("first EntityView is empty"); + throw Error("first EntityView is empty"); } if (view_atoms.GetAtomCount()==0){ - throw std::runtime_error("second EntityView is empty"); + throw Error("second EntityView is empty"); } std::vector<Real> dist, masses_cm; dist.reserve(ceil(traj.GetFrameCount()/float(stride))); @@ -211,10 +211,10 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c { CheckHandleValidity(traj); if (view_ring1.GetAtomCount()==0){ - throw std::runtime_error("first EntityView is empty"); + throw Error("first EntityView is empty"); } if (view_ring2.GetAtomCount()==0){ - throw std::runtime_error("second EntityView is empty"); + throw Error("second EntityView is empty"); } std::vector<Real> dist, masses_ring1,masses_ring2; dist.reserve(ceil(traj.GetFrameCount()/float(stride))); @@ -239,7 +239,7 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c { CheckHandleValidity(traj); if (prot_seg.GetAtomCount()==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } std::vector<unsigned long> indices_ca; geom::Line3 axis; @@ -266,7 +266,7 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c { CheckHandleValidity(traj); if (prot_seg.GetAtomCount()==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } std::vector<unsigned long> indices_ca; geom::Line3 axis; @@ -287,7 +287,7 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c { CheckHandleValidity(traj); if (prot_seg.GetAtomCount()==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } std::vector<unsigned long> indices_ca; geom::Plane best_plane; @@ -308,7 +308,7 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c { CheckHandleValidity(traj); if (prot_seg.GetAtomCount()==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } std::vector<unsigned long> indices_c,indices_o, indices_n, indices_ca; std::vector<Real> helicity; @@ -329,14 +329,14 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c if (to==-1)to=traj.GetFrameCount(); unsigned int n_atoms=selection.GetAtomCount(); if (to<from) { - throw std::runtime_error("to smaller than from"); + throw Error("to smaller than from"); } unsigned int n_frames=ceil((to-from)/stride); if (n_atoms==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } if (n_frames<=1) { - throw std::runtime_error("number of frames is too small"); + throw Error("number of frames is too small"); } std::vector<unsigned long> indices; std::vector<geom::Vec3> mean_positions; @@ -368,14 +368,14 @@ std::vector<Real> AnalyzeAromaticRingInteraction(const CoordGroupHandle& traj, c if (to==-1)to=traj.GetFrameCount(); unsigned int n_atoms=selection.GetAtomCount(); if (to<from) { - throw std::runtime_error("to smaller than from"); + throw Error("to smaller than from"); } unsigned int n_frames=ceil((to-from)/stride); if (n_atoms==0){ - throw std::runtime_error("EntityView is empty"); + throw Error("EntityView is empty"); } if (n_frames<=1) { - throw std::runtime_error("number of frames is too small"); + throw Error("number of frames is too small"); } Real rmsf=0.0; geom::Vec3 v; diff --git a/modules/mol/base/pymod/export_editors.cc b/modules/mol/base/pymod/export_editors.cc index 6cee09765c2ce84e7a07bbddf4d05abebdd84cf6..e53a02d35ffc39d35e826c9f34938dfd2821c4a1 100644 --- a/modules/mol/base/pymod/export_editors.cc +++ b/modules/mol/base/pymod/export_editors.cc @@ -82,13 +82,13 @@ void set_pos2_t(XCSEditor& e, const AtomHandleList& alist, object pyobj) size_t acount = alist.size(); if(!PyArray_Check(pyobj.ptr())) { - throw std::runtime_error("expected a numpy array"); + throw Error("expected a numpy array"); return; } PyArrayObject* na=reinterpret_cast<PyArrayObject*>(pyobj.ptr()); if(PyArray_NDIM(na)!=2 || PyArray_DIM(na,0)!=int(acount) || PyArray_DIM(na,1)!=3) { - throw std::runtime_error("excpected a numpy array of shape (NAtoms, 3)"); + throw Error("excpected a numpy array of shape (NAtoms, 3)"); return; } @@ -106,20 +106,20 @@ void set_pos2_t(XCSEditor& e, const AtomHandleList& alist, object pyobj) e.SetAtomTransformedPos(alist,reinterpret_cast<double*>(PyArray_DATA(na))); } } else { - throw std::runtime_error("expected a numpy array of type float or double"); + throw Error("expected a numpy array of type float or double"); return; } } else { // non-contiguous #if 0 - throw std::runtime_error("expected contiguous numpy array"); + throw Error("expected contiguous numpy array"); #else if(PyArray_TYPE(na)==NPY_FLOAT) { set_pos2_nc_t<float,O>(e,alist,na); } else if(PyArray_TYPE(na)==NPY_DOUBLE) { set_pos2_nc_t<double,O>(e,alist,na); } else { - throw std::runtime_error("expected a numpy array of type float or double"); + throw Error("expected a numpy array of type float or double"); return; } #endif @@ -172,7 +172,7 @@ void set_pos(XCSEditor& e, object o1, object o2, bool trans) } #else - throw std::runtime_error("SetAtom*Pos(...,ndarray) not available, because numpy support not compiled in"); + throw Error("SetAtom*Pos(...,ndarray) not available, because numpy support not compiled in"); #endif } diff --git a/modules/mol/base/pymod/export_entity_property_mapper.cc b/modules/mol/base/pymod/export_entity_property_mapper.cc index fa271bed83a04df8773f8110e773b94e5a7676e1..df008566a416b74fe97d151f76660b2ab29157e8 100644 --- a/modules/mol/base/pymod/export_entity_property_mapper.cc +++ b/modules/mol/base/pymod/export_entity_property_mapper.cc @@ -40,7 +40,7 @@ EntityPropertyMapper create_epm(const String& prop_name, char level) case 'u': return EntityPropertyMapper(prop_name, Prop::UNSPECIFIED); default: - throw std::runtime_error(String("unknown property level '")+level+"'"); + throw Error(String("unknown property level '")+level+"'"); } } diff --git a/modules/mol/base/src/chain_type.cc b/modules/mol/base/src/chain_type.cc index 6b3841d8909e4378db492db306efe86ece0bba44..2c6c091b9b9cb37608c8a067175ae64eb7961e4b 100644 --- a/modules/mol/base/src/chain_type.cc +++ b/modules/mol/base/src/chain_type.cc @@ -17,7 +17,7 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ -#include <stdexcept> +#include <ost/message.hh> #include "chain_type.hh" namespace ost { namespace mol { @@ -52,7 +52,7 @@ ChainType ChainTypeFromString(StringRef identifier) return CHAINTYPE_UNKNOWN; } - throw std::runtime_error("Unrecognised chain type descriptor found: '" + + throw Error("Unrecognised chain type descriptor found: '" + identifier.str() +"'!"); } @@ -92,7 +92,7 @@ String StringFromChainType(ChainType type) std::stringstream ss("Unknonw ChainType item found: '"); ss << type << "'!"; - throw std::runtime_error(ss.str()); + throw Error(ss.str()); } }} //ns diff --git a/modules/mol/base/src/chain_type.hh b/modules/mol/base/src/chain_type.hh index 4167280fc6a7a7b0b09376d6da0665532f2a1831..513cb1d51b3c295376d4b7094844b58967091336 100644 --- a/modules/mol/base/src/chain_type.hh +++ b/modules/mol/base/src/chain_type.hh @@ -47,7 +47,7 @@ typedef enum { /// \param identifier StringRef to be translated /// /// \return The ChainType corresponding to the input, throws a -/// std::runtime_error on unknown type +/// ost:Error on unknown type ChainType DLLEXPORT_OST_MOL ChainTypeFromString(const StringRef identifier); /// \brief Create a ChainType item for a given string @@ -55,14 +55,14 @@ ChainType DLLEXPORT_OST_MOL ChainTypeFromString(const StringRef identifier); /// \param identifier String to be translated /// /// \return The ChainType corresponding to the input, throws a -/// std::runtime_error on unknown type +/// ost::Error on unknown type ChainType DLLEXPORT_OST_MOL ChainTypeFromString(const String& identifier); /// \brief Return the String identifier for a given type /// /// \param type ChainType to be translated /// -/// \return String corresponding to the input, throws a std::runtime_error on +/// \return String corresponding to the input, throws a ost::Error on /// unknown type String DLLEXPORT_OST_MOL StringFromChainType(ChainType type); diff --git a/modules/mol/base/src/coord_frame.cc b/modules/mol/base/src/coord_frame.cc index 97803e242b4f057c9e02a166fd303334c0f6af72..52907d7f771aea5aa1e980cc11e6ba1546d7ae1c 100644 --- a/modules/mol/base/src/coord_frame.cc +++ b/modules/mol/base/src/coord_frame.cc @@ -145,7 +145,7 @@ namespace ost { namespace mol { int count_ref=reference_view.GetAtomCount(); int count_sele=sele_view.GetAtomCount(); if (count_ref!=count_sele){ - throw std::runtime_error("atom counts of the two views are not equal"); + throw Error("atom counts of the two views are not equal"); } std::vector<unsigned long> indices_sele; std::vector<geom::Vec3> ref_pos; @@ -285,10 +285,10 @@ namespace ost { namespace mol { dist.reserve(n_atoms-2); dist2.reserve(n_atoms-2); if (n_atoms!=indices_n.size()||n_atoms!=indices_c.size()||n_atoms!=indices_o.size()){ - throw std::runtime_error("not same numbers of CA, C, O and N atoms in the selection"); + throw Error("not same numbers of CA, C, O and N atoms in the selection"); } if (n_atoms<=5){ - throw std::runtime_error("At least five residues are needed to calulate an alpha helix similarity"); + throw Error("At least five residues are needed to calulate an alpha helix similarity"); } c=(*this)[indices_c[0]]; n_next=(*this)[indices_n[1]]; @@ -358,7 +358,7 @@ namespace ost { namespace mol { indices_ca.reserve(residues.size()); //for (ResidueViewList::const_iterator res=residues.begin()+1, // e=residues.end(); res!=e-1; ++res){ - // if (!InSequence((*res).GetHandle(),(*(res+1)).GetHandle())) throw std::runtime_error("Residues are not in a continuous sequence"); + // if (!InSequence((*res).GetHandle(),(*(res+1)).GetHandle())) throw Error("Residues are not in a continuous sequence"); //} for (ResidueViewList::const_iterator res=residues.begin(), e=residues.end(); res!=e; ++res) { @@ -378,7 +378,7 @@ namespace ost { namespace mol { indices_o.reserve(residues.size()); for (ResidueViewList::const_iterator res=residues.begin()+1, e=residues.end(); res!=e-1; ++res){ - if (!InSequence((*res).GetHandle(),(*(res+1)).GetHandle())) throw std::runtime_error("Residues are not in a continuous sequence"); + if (!InSequence((*res).GetHandle(),(*(res+1)).GetHandle())) throw Error("Residues are not in a continuous sequence"); } for (ResidueViewList::const_iterator res=residues.begin(), e=residues.end(); res!=e; ++res) { diff --git a/modules/mol/base/src/not_connected_error.hh b/modules/mol/base/src/not_connected_error.hh index cce9f1b4f8b6bf6d227716b048cf0ecd0217f9a9..ac736c74e4eff141c20a3345fd05ac9e0c31e948 100644 --- a/modules/mol/base/src/not_connected_error.hh +++ b/modules/mol/base/src/not_connected_error.hh @@ -26,7 +26,7 @@ namespace ost { namespace mol { /// \brief Error to indicate that two atoms that are supposed to be connected /// are not. -class DLLEXPORT_OST_MOL NotConnectedError : public Error { +class DLLEXPORT NotConnectedError : public Error { public: NotConnectedError(AtomHandle one, AtomHandle two); virtual ~NotConnectedError() throw() {} diff --git a/modules/mol/base/src/property_id.hh b/modules/mol/base/src/property_id.hh index 3632f996ac468a9891139a69a107d87aa2f8d711..981b747cfe500b8b7f41c8b294036527a29522d3 100644 --- a/modules/mol/base/src/property_id.hh +++ b/modules/mol/base/src/property_id.hh @@ -87,15 +87,13 @@ Prop::ID DLLEXPORT_OST_MOL PropertyIDFromString(const String& prop); Prop DLLEXPORT_OST_MOL PropertyFromString(const String& prop); -struct DLLEXPORT PropertyError: public std::exception +struct DLLEXPORT PropertyError: public ost::Error { PropertyError(ost::mol::Prop::ID prop): + ost::Error("invalid property"), prop_(prop) {} virtual ~PropertyError() throw() {} - virtual const char* what() const throw() { - return "invalid property"; - } ost::mol::Prop::ID Prop() const { diff --git a/modules/mol/base/src/query_error.cc b/modules/mol/base/src/query_error.cc index 1cdce0fe205b6ed04a0aa4d4fa3a5d42cca8f638..34bb3b83c919e7b3fcea9fd54019b908de88b27e 100644 --- a/modules/mol/base/src/query_error.cc +++ b/modules/mol/base/src/query_error.cc @@ -39,7 +39,7 @@ String QueryError::GetFormattedMessage() const throw() { QueryError::QueryError(const String& query, const QueryErrorDesc& desc) throw() - : query_(query),desc_(desc) { + : ost::Error(""),query_(query),desc_(desc) { } QueryError::~QueryError() throw() { diff --git a/modules/mol/base/src/query_error.hh b/modules/mol/base/src/query_error.hh index 4d2fe8639fb8a63ba2431a8db406d98e44f03d9e..84d0164997afe8a3e4d9365ef8c75b8cef064d8b 100644 --- a/modules/mol/base/src/query_error.hh +++ b/modules/mol/base/src/query_error.hh @@ -19,6 +19,7 @@ #ifndef OST_QUERY_ERROR_HH #define OST_QUERY_ERROR_HH +#include <ost/message.hh> #include <ost/range.hh> #include <ost/mol/module_config.hh> @@ -35,7 +36,7 @@ struct DLLEXPORT_OST_MOL QueryErrorDesc { Range range; }; -class DLLEXPORT_OST_MOL QueryError : public std::exception { +class DLLEXPORT_OST_MOL QueryError : public ost::Error { public: QueryError(const String& query, const QueryErrorDesc& desc) throw(); diff --git a/modules/mol/base/tests/test_chain.cc b/modules/mol/base/tests/test_chain.cc index e6587c2992be6486d31bb173625db9e9dbc670ac..ee4d933d0c095766079bb4278774d41d97a74ae3 100644 --- a/modules/mol/base/tests/test_chain.cc +++ b/modules/mol/base/tests/test_chain.cc @@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE(chain_type) CHAINTYPE_POLY_DN_RN); BOOST_CHECK(ChainTypeFromString("other") == CHAINTYPE_UNKNOWN); BOOST_CHECK_THROW(ChainTypeFromString("supposed to fail"), - std::runtime_error); + Error); // chain type -> string BOOST_CHECK(StringFromChainType(CHAINTYPE_POLY) == "polymer"); @@ -322,7 +322,7 @@ BOOST_AUTO_TEST_CASE(chain_type) "polydeoxyribonucleotide/polyribonucleotide hybrid"); BOOST_CHECK(StringFromChainType(CHAINTYPE_UNKNOWN) == "other"); BOOST_CHECK_THROW(StringFromChainType(CHAINTYPE_N_CHAINTYPES), - std::runtime_error); + Error); } BOOST_AUTO_TEST_CASE(chain_description) diff --git a/modules/mol/base/tests/test_query.cc b/modules/mol/base/tests/test_query.cc index 52fece59d284408ef8e5e7cdc2adda6d1f48f836..9f85dbcf1a8585f584354d525ff76f261af68d79 100644 --- a/modules/mol/base/tests/test_query.cc +++ b/modules/mol/base/tests/test_query.cc @@ -270,15 +270,15 @@ BOOST_AUTO_TEST_CASE(test_query_throw) EntityHandle e=make_query_test_entity(); BOOST_CHECK_NO_THROW(e.Select("gatestpropa:0=1")); BOOST_CHECK_NO_THROW(e.Select("gatestpropa:1=1")); - BOOST_CHECK_THROW(e.Select("gatestpropa=1"), std::exception); + BOOST_CHECK_THROW(e.Select("gatestpropa=1"), ost::Error); BOOST_CHECK_NO_THROW(e.Select("grtestpropr:0=1")); BOOST_CHECK_NO_THROW(e.Select("grtestpropr:1=1")); - BOOST_CHECK_THROW(e.Select("grtestpropr=1"), std::exception); + BOOST_CHECK_THROW(e.Select("grtestpropr=1"), ost::Error); BOOST_CHECK_NO_THROW(e.Select("gctestprop_c:0=1")); BOOST_CHECK_NO_THROW(e.Select("gctestprop_c:1=1")); - BOOST_CHECK_THROW(e.Select("ganotsetprop=1"), std::exception); - BOOST_CHECK_THROW(e.Select("grnotsetprop=1"), std::exception); - BOOST_CHECK_THROW(e.Select("gcnotsetprop=1"), std::exception); + BOOST_CHECK_THROW(e.Select("ganotsetprop=1"), ost::Error); + BOOST_CHECK_THROW(e.Select("grnotsetprop=1"), ost::Error); + BOOST_CHECK_THROW(e.Select("gcnotsetprop=1"), ost::Error); BOOST_CHECK_NO_THROW(e.Select("ganotsetprop:0=1")); BOOST_CHECK_NO_THROW(e.Select("grnotsetprop:0=1")); BOOST_CHECK_NO_THROW(e.Select("gcnotsetprop:0=1")); diff --git a/modules/seq/base/src/alignment_handle.cc b/modules/seq/base/src/alignment_handle.cc index c91fa3bbc93168a82b2870d31ed4f9c3f115d537..8b8f2fc282bd50c14f1c2cce31130e59fac29e68 100644 --- a/modules/seq/base/src/alignment_handle.cc +++ b/modules/seq/base/src/alignment_handle.cc @@ -71,7 +71,7 @@ void AlignmentHandle::AddSequence(const ConstSequenceHandle& sequence) } if (impl_->GetCount()>0 && impl_->GetSequence(0)->GetLength()!=sequence.GetLength()) { - throw std::runtime_error("sequence doesn't have the same length as the " + throw Error("sequence doesn't have the same length as the " "alignment"); } return impl_->AddSequence(sequence.Impl()); @@ -141,7 +141,7 @@ AlignmentHandle AlignmentFromSequenceList(const SequenceList& seq_list) if (seq_list.IsValid() && seq_list.SequencesHaveEqualLength()) { return AlignmentHandle(seq_list.Impl()); } - throw std::runtime_error("sequences have different lengths"); + throw Error("sequences have different lengths"); } ConstSequenceList AlignmentHandle::GetSequences() const @@ -289,7 +289,7 @@ mol::EntityViewPair AlignmentHandle::GetMatchingBackboneViews(int idx0, int idx1 const impl::SequenceImpl& s1=*impl_->GetSequence(idx0).get(); const impl::SequenceImpl& s2=*impl_->GetSequence(idx1).get(); if (!s1.HasAttachedView() || !s2.HasAttachedView()) { - throw std::runtime_error("both sequences must have a view attached"); + throw Error("both sequences must have a view attached"); } mol::EntityView v1=s1.GetAttachedView().CreateEmptyView(); mol::EntityView v2=s2.GetAttachedView().CreateEmptyView(); diff --git a/modules/seq/base/tests/test_alignment.cc b/modules/seq/base/tests/test_alignment.cc index 6b438e304e06367e76e2667643af4ece2aad6e06..a70c19b226cb46140aa1fb70b5a8518b581156bd 100644 --- a/modules/seq/base/tests/test_alignment.cc +++ b/modules/seq/base/tests/test_alignment.cc @@ -65,11 +65,11 @@ BOOST_AUTO_TEST_CASE(alignment_triv) BOOST_CHECK_NO_THROW(a.AddSequence(CreateSequence("S1","-asdf-"))); BOOST_CHECK_THROW(a.AddSequence(SequenceHandle()),InvalidSequence); BOOST_CHECK_THROW(a.AddSequence(CreateSequence("S2","-asdf-f")), - std::runtime_error); + Error); SequenceList list = CreateSequenceList(); list.AddSequence(CreateSequence("S1", "-asdf-")); list.AddSequence(CreateSequence("S2", "fasdfas")); - BOOST_CHECK_THROW(AlignmentFromSequenceList(list), std::runtime_error); + BOOST_CHECK_THROW(AlignmentFromSequenceList(list), Error); list = CreateSequenceList(); list.AddSequence(CreateSequence("S1", "-asdf-")); list.AddSequence(CreateSequence("S2", "fasdfa"));