From e0c2531f53886261445737eb62f76a34199f6d1a Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 20 Sep 2020 23:50:09 +0100 Subject: [PATCH] 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. --- common/settings/json_settings.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index 5f54774d13..e27257f440 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -51,7 +51,16 @@ JSON_SETTINGS::JSON_SETTINGS( const wxString& aFilename, SETTINGS_LOC aLocation, m_schemaVersion( aSchemaVersion ), 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( new PARAM( "meta.version", &m_schemaVersion, m_schemaVersion, true ) ); @@ -83,10 +92,8 @@ void JSON_SETTINGS::Load() } catch( ... ) { - // Skip unreadable parameters in file: -#ifdef DEBUG - wxLogMessage( wxString::Format( "param '%s' load err", param->GetJsonPath().c_str() ) ); -#endif + // Skip unreadable parameters in file + wxLogTrace( traceSettings, "param '%s' load err", param->GetJsonPath().c_str() ); } } }