Add more/better error messages for file i/o problems.
This commit is contained in:
parent
529521a7ba
commit
01882d3103
|
@ -514,20 +514,15 @@ void STRING_FORMATTER::StripUseless()
|
|||
|
||||
//-----<FILE_OUTPUTFORMATTER>----------------------------------------
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue