Catch IO_ERRORs that we throw

FILEOUTPUT_FORMATTER likes to throw when it gets an issue.  We need to
catch this to avoid the app falling apart

Fixes https://gitlab.com/kicad/code/kicad/issues/11516

(cherry picked from commit 4d47857738)
This commit is contained in:
Seth Hillbrand 2022-05-02 15:14:10 -07:00
parent f6f316bd8c
commit 2079d15b3f
1 changed files with 13 additions and 2 deletions

View File

@ -95,9 +95,20 @@ NETLIST_EXPORTER_PSPICE::GetSpiceTuningCommand( const wxString& aSymbol ) const
bool NETLIST_EXPORTER_PSPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
FILE_OUTPUTFORMATTER outputFile( aOutFileName, wxT( "wt" ), '\'' );
try
{
FILE_OUTPUTFORMATTER outputFile( aOutFileName, wxT( "wt" ), '\'' );
return Format( &outputFile, aNetlistOptions );
return Format( &outputFile, aNetlistOptions );
}
catch( IO_ERROR& )
{
wxString msg;
msg.Printf( _( "Failed to create file '%s'." ), aOutFileName );
DisplayError( m_schematic, msg );
return false;
}
}