Menu

Inaccurate error reporting

Developer
Anonymous
2003-01-07
2003-04-06
  • Anonymous

    Anonymous - 2003-01-07

    I don't know if this is an oversight, or if it's even a problem, but when implementing:

    bool success = worldXml->LoadFile();
      if( !success )
      {
        cout << worldXml->ErrorDesc() << endl;
        error = false;
      }

    ErrorDesc() would report back with "Failed to open file"
    in both cases of fopen returning NULL, and when a parse error occurred.  I changed the code:

    bool TiXmlDocument::LoadFile( const char* filename )
    {
    ...
        fclose( file );

        Parse( data.c_str() );
        if (  !Error() )
        {
            return true;
         }
    }
    SetError( TIXML_ERROR_OPENING_FILE );
    return false;
    ...

    in tinyxml.cpp to

    bool TiXmlDocument::LoadFile( const char* filename )
    ...
        fclose( file );

        Parse( data.c_str() );
        if (  !Error() )
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        SetError( TIXML_ERROR_OPENING_FILE );
        return false;
    }
    ...

    It now reports back both kinds of errors properly.  The original code simply reinitialized the error description regardless.  Now it doesn't.  This code is several months old and this fix may already be known about and implemented.
    Will this fix will cause any problems with the rest of the code?

    --Hermit

     
    • Anonymous

      Anonymous - 2003-01-07

      I now see that the post "Bug (and fix)" by wasteland already addressed this issue.  

      Hermit

       
    • Yves Berquin

      Yves Berquin - 2003-04-06

      Thanks for the fix. It's in 2.1.5 (to come)

       

Log in to post a comment.

MongoDB Logo MongoDB