Improve error message granularity

When saving a library, check and report on libraries that do not exist
as well as those that exist but are read-only.

Fixes: lp:1769190
* https://bugs.launchpad.net/kicad/+bug/1769190
This commit is contained in:
Seth Hillbrand 2018-05-04 09:10:51 -07:00
parent e0ca5bab11
commit 5ca6864a40
1 changed files with 12 additions and 4 deletions

View File

@ -126,6 +126,7 @@ public:
wxString GetPath() const { return m_lib_path.GetPath(); }
bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
MODULE_MAP& GetModules() { return m_modules; }
// Most all functions in this class throw IO_ERROR exceptions. There are no
@ -2070,10 +2071,17 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
if( !m_cache->IsWritable() )
{
wxString msg = wxString::Format(
_( "Library \"%s\" is read only" ),
GetChars( aLibraryPath )
);
wxString msg;
if( !m_cache->Exists() )
{
msg = wxString::Format( _ ( "Library \"%s\" does not exist" ),
GetChars( aLibraryPath ) );
}
else
{
msg = wxString::Format( _( "Library \"%s\" is read only" ),
GetChars( aLibraryPath ) );
}
THROW_IO_ERROR( msg );
}