Ignore:
Timestamp:
09/01/15 17:15:41 (9 years ago)
Author:
rlacroix
Message:

Improve the error messages for axis and domains.

  • Fix some errors in the checks.
  • Fix some typos in the messages and generally try to make them clearer.
  • Always display the context and object IDs.
  • Always display the invalid values for easier debugging.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r676 r679  
    135135   { 
    136136      if (this->n_glo.isEmpty()) 
    137          ERROR("CAxis::checkAttributes(void)", 
    138                << "Attribute <n_glo> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be specified"); 
     137        ERROR("CAxis::checkAttributes(void)", 
     138              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     139              << "The axis is wrongly defined, attribute 'n_glo' must be specified"); 
    139140      StdSize size = this->n_glo.getValue(); 
    140141 
     
    143144      if (!this->begin.isEmpty()) 
    144145      { 
    145         StdSize ibegin = this->begin.getValue(); 
    146         if ((ibegin < 0) || (ibegin > size-1)) 
     146        if (begin < 0 || begin > size - 1) 
    147147          ERROR("CAxis::checkAttributes(void)", 
    148                 << "Attribute <ibegin> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be non-negative and smaller than size-1"); 
     148                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     149                << "The axis is wrongly defined, attribute 'begin' (" << begin.getValue() << ") must be non-negative and smaller than size-1 (" << size - 1 << ")."); 
    149150      } 
    150151      else this->begin.setValue(0); 
     
    152153      if (!this->n.isEmpty()) 
    153154      { 
    154         StdSize ni = this->n.getValue(); 
    155         if ((ni < 0) || (ni > size)) 
     155        if (n < 0 || n > size) 
    156156          ERROR("CAxis::checkAttributes(void)", 
    157                 << "Attribute <ni> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be non-negative and smaller than size"); 
     157                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     158                << "The axis is wrongly defined, attribute 'n' (" << n.getValue() << ") must be non-negative and smaller than size (" << size << ")."); 
    158159      } 
    159160      else this->n.setValue(size); 
     
    161162      StdSize true_size = value.numElements(); 
    162163      if (this->n.getValue() != true_size) 
    163          ERROR("CAxis::checkAttributes(void)", 
    164                << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute"); 
     164        ERROR("CAxis::checkAttributes(void)", 
     165              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     166              << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
    165167 
    166168      this->checkData(); 
     
    173175   { 
    174176      if (data_begin.isEmpty()) data_begin.setValue(0); 
    175       if (!data_n.isEmpty() && data_n.getValue() <= 0) 
     177 
     178      if (data_n.isEmpty()) 
     179      { 
     180        data_n.setValue(n); 
     181      } 
     182      else if (data_n.getValue() < 0) 
    176183      { 
    177184        ERROR("CAxis::checkData(void)", 
    178               << "Data dimension is negative (data_n)."); 
    179       } 
    180       else if (data_n.isEmpty()) 
    181         data_n.setValue(n.getValue()); 
     185              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     186              << "The data size should be strictly positive ('data_n' = " << data_n.getValue() << ")."); 
     187      } 
    182188 
    183189      if (data_index.isEmpty()) 
    184190      { 
    185         int dn = data_n.getValue(); 
    186         data_index.resize(dn); 
    187         for (int i = 0; i < dn; ++i) data_index(i) = i; 
     191        data_index.resize(data_n); 
     192        for (int i = 0; i < data_n; ++i) data_index(i) = i; 
    188193      } 
    189194   } 
     
    199204      { 
    200205         if (mask.extent(0) != n) 
    201             ERROR("CAxis::checkMask(void)", 
    202                   << "the mask has not the same size than the local axis" << endl 
    203                   << "Local size is " << n << "x" << endl 
    204                   << "Mask size is " << mask.extent(0) << "x"); 
    205       } 
    206       else // (!mask.hasValue()) 
    207       { // Si aucun masque n'est défini, 
    208         // on en crée un nouveau qui valide l'intégralité du domaine. 
     206           ERROR("CAxis::checkMask(void)", 
     207                 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     208                 << "The mask does not have the same size as the local domain." << std::endl 
     209                 << "Local size is " << n.getValue() << "." << std::endl 
     210                 << "Mask size is " << mask.extent(0) << "."); 
     211      } 
     212      else // (mask.isEmpty()) 
     213      { // If no mask was defined, we create a default one without any masked point. 
    209214         mask.resize(n); 
    210          for (int i = 0; i < n.getValue(); ++i) 
     215         for (int i = 0; i < n; ++i) 
    211216         { 
    212217           mask(i) = true; 
     
    221226      if (bounds.extent(0) != n || bounds.extent(1) != 2) 
    222227          ERROR("CAxis::checkAttributes(void)", 
    223                 << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2" << endl 
    224                 << "Axis size is " << n << endl 
    225                 << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1)); 
     228                << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis size x 2." << std::endl 
     229                << "Axis size is " << n.getValue() << "." << std::endl 
     230                << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1) << "."); 
    226231      hasBounds_ = true; 
    227232    } 
     
    259264            break; 
    260265           default : 
    261              ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     266             ERROR("bool CAxis::dispatchEvent(CEventServer& event)", 
    262267                    << "Unknown Event"); 
    263268           return false; 
Note: See TracChangeset for help on using the changeset viewer.