From e67eb17f93d395d0e6306392bf7c31bcae795000 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 4 Apr 2013 07:59:09 +0000 Subject: [PATCH] Protections on Fields against null pointers --- src/MEDCoupling/MEDCouplingNatureOfField.cxx | 20 ++++++++++++++++++-- src/MEDCoupling/MEDCouplingNatureOfField.hxx | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) 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