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
This commit is contained in:
Seth Hillbrand 2022-05-02 15:14:10 -07:00
parent 08c216e796
commit 4d47857738
1 changed files with 13 additions and 2 deletions

View File

@ -63,9 +63,20 @@ wxString NETLIST_EXPORTER_PSPICE::GetSpiceDevice( const wxString& aSymbol ) cons
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;
}
}