From 5ca6864a4036ac91c8cb846ae69c876e87a7fd8d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 4 May 2018 09:10:51 -0700 Subject: [PATCH] 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 --- pcbnew/kicad_plugin.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 26562a2484..d4f1841946 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -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 ); }