diff --git a/common/richio.cpp b/common/richio.cpp index 2f32a245a2..a8eefce9af 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -514,20 +514,15 @@ void STRING_FORMATTER::StripUseless() //--------------------------------------------- -FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER( const wxString& aFileName, - const wxChar* aMode, char aQuoteChar ): +FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER( const wxString& aFileName, const wxChar* aMode, + char aQuoteChar ): OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ), m_filename( aFileName ) { m_fp = wxFopen( aFileName, aMode ); if( !m_fp ) - { - wxString msg = wxString::Format( - _( "cannot open or save file \"%s\"" ), - m_filename.GetData() ); - THROW_IO_ERROR( msg ); - } + THROW_IO_ERROR( std::strerror( errno ) ); } @@ -540,13 +535,8 @@ FILE_OUTPUTFORMATTER::~FILE_OUTPUTFORMATTER() void FILE_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount ) { - if( 1 != fwrite( aOutBuf, aCount, 1, m_fp ) ) - { - wxString msg = wxString::Format( - _( "error writing to file \"%s\"" ), - m_filename.GetData() ); - THROW_IO_ERROR( msg ); - } + if( fwrite( aOutBuf, (unsigned) aCount, 1, m_fp ) != 1 ) + THROW_IO_ERROR( std::strerror( errno ) ); } diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 0e0c207b3f..bc52f17630 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -148,10 +148,16 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) { archLib->Save( false ); } - catch( ... /* IO_ERROR ioe */ ) + catch( const IO_ERROR& ioe ) { errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName ); - DisplayError( this, errorMsg ); + DisplayErrorMessage( this, errorMsg, ioe.What() ); + return false; + } + catch( std::exception& error ) + { + errorMsg.Printf( _( "Failed to save symbol library file \"%s\"" ), aFileName ); + DisplayErrorMessage( this, errorMsg, error.what() ); return false; }