Catch exception inside JSON_SETTINGS constructor

This exception will probably never be thrown in real life,
but the constructors are normally noexcept, so throwing
any exception from the json library causes Coverity to
have a fit.
This commit is contained in:
Ian McInerney 2020-09-20 23:50:09 +01:00
parent 2becd368d9
commit e0c2531f53
1 changed files with 12 additions and 5 deletions

View File

@ -51,7 +51,16 @@ JSON_SETTINGS::JSON_SETTINGS( const wxString& aFilename, SETTINGS_LOC aLocation,
m_schemaVersion( aSchemaVersion ), m_schemaVersion( aSchemaVersion ),
m_manager( nullptr ) m_manager( nullptr )
{ {
( *this )[PointerFromString( "meta.filename" )] = GetFullFilename(); try
{
( *this )[PointerFromString( "meta.filename" )] = GetFullFilename();
}
catch( ... )
{
wxLogTrace( traceSettings, "Error: Could not create filename field for %s",
GetFullFilename() );
}
m_params.emplace_back( m_params.emplace_back(
new PARAM<int>( "meta.version", &m_schemaVersion, m_schemaVersion, true ) ); new PARAM<int>( "meta.version", &m_schemaVersion, m_schemaVersion, true ) );
@ -83,10 +92,8 @@ void JSON_SETTINGS::Load()
} }
catch( ... ) catch( ... )
{ {
// Skip unreadable parameters in file: // Skip unreadable parameters in file
#ifdef DEBUG wxLogTrace( traceSettings, "param '%s' load err", param->GetJsonPath().c_str() );
wxLogMessage( wxString::Format( "param '%s' load err", param->GetJsonPath().c_str() ) );
#endif
} }
} }
} }