DIALOG_SYMBOL_FIELDS_TABLE::OnExport(): better error messages.
This commit is contained in:
parent
bf29b25190
commit
e48256d41a
|
@ -1232,23 +1232,25 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnExport( wxCommandEvent& aEvent )
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString path = m_outputFileName->GetValue();
|
wxString path = m_outputFileName->GetValue();
|
||||||
|
|
||||||
|
if( path.IsEmpty() )
|
||||||
|
{
|
||||||
|
DisplayError( this, _( "No filename specified in exporter" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
path = ExpandTextVars( path, &textResolver );
|
path = ExpandTextVars( path, &textResolver );
|
||||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||||
|
|
||||||
wxFileName outputFile = wxFileName::FileName( path );
|
wxFileName outputFile = wxFileName::FileName( path );
|
||||||
|
|
||||||
auto displayErr = [&]()
|
|
||||||
{
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf( _( "Could not write BOM output to '%s'." ), outputFile.GetPath() );
|
|
||||||
DisplayError( this, msg );
|
|
||||||
};
|
|
||||||
|
|
||||||
if( !EnsureFileDirectoryExists( &outputFile,
|
if( !EnsureFileDirectoryExists( &outputFile,
|
||||||
Prj().AbsolutePath( m_parent->Schematic().GetFileName() ),
|
Prj().AbsolutePath( m_parent->Schematic().GetFileName() ),
|
||||||
&NULL_REPORTER::GetInstance() ) )
|
&NULL_REPORTER::GetInstance() ) )
|
||||||
{
|
{
|
||||||
displayErr();
|
msg.Printf( _( "Could not open/create path '%s'." ), outputFile.GetPath() );
|
||||||
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,7 +1258,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnExport( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( !out.IsOpened() )
|
if( !out.IsOpened() )
|
||||||
{
|
{
|
||||||
displayErr();
|
msg.Printf( _( "Could not create BOM output '%s'." ), outputFile.GetFullPath() );
|
||||||
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,11 +1267,11 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnExport( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( !out.Write( m_textOutput->GetValue() ) )
|
if( !out.Write( m_textOutput->GetValue() ) )
|
||||||
{
|
{
|
||||||
displayErr();
|
msg.Printf( _( "Could not write BOM output '%s'." ), outputFile.GetFullPath() );
|
||||||
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString msg;
|
|
||||||
msg.Printf( _( "Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
|
msg.Printf( _( "Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
|
||||||
DisplayInfoMessage( this, msg );
|
DisplayInfoMessage( this, msg );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue