From 2079d15b3f933c86dbb5b8e7d7d2df2aaec5b754 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 2 May 2022 15:14:10 -0700 Subject: [PATCH] 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 4d47857738ab211412d58185c0032a36e85f9546) --- .../netlist_exporters/netlist_exporter_pspice.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index ada27723cd..0863b482c5 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -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; + } }