From: ageay Date: Thu, 4 Apr 2013 07:59:09 +0000 (+0000) Subject: Protections on Fields against null pointers X-Git-Tag: V6_main_FINAL~210 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e67eb17f93d395d0e6306392bf7c31bcae795000;p=tools%2Fmedcoupling.git Protections on Fields against null pointers --- diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.cxx b/src/MEDCoupling/MEDCouplingNatureOfField.cxx index da684878f..3c44332fb 100644 --- a/src/MEDCoupling/MEDCouplingNatureOfField.cxx +++ b/src/MEDCoupling/MEDCouplingNatureOfField.cxx @@ -21,6 +21,7 @@ #include "MEDCouplingNatureOfField.hxx" #include +#include namespace ParaMEDMEM { @@ -37,7 +38,11 @@ namespace ParaMEDMEM { const int *pos=std::find(POS_OF_NATUREOFFIELD,POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES,(int)nat); if(pos==POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES) - throw INTERP_KERNEL::Exception("MEDCouplingNatureOfField::getRepr : Unrecognized nature of field !"); + { + std::ostringstream oss; oss << "MEDCouplingNatureOfField::getRepr : Unrecognized nature of field ! "; + oss << GetAllPossibilitiesStr() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } std::size_t pos2=std::distance(POS_OF_NATUREOFFIELD,pos); return REPR_OF_NATUREOFFIELD[pos2]; } @@ -50,5 +55,16 @@ namespace ParaMEDMEM std::size_t pos2=std::distance(POS_OF_NATUREOFFIELD,pos); return std::string(REPR_OF_NATUREOFFIELD[pos2]); } + + std::string MEDCouplingNatureOfField::GetAllPossibilitiesStr() + { + std::ostringstream oss; oss << "Possibilities are : "; + for(int i=0;i