Commit 8234966a authored by Dick Hollenbeck's avatar Dick Hollenbeck

if https:// GET fails, report the URL

parent 44ca3530
...@@ -115,31 +115,29 @@ struct IO_ERROR // : std::exception ...@@ -115,31 +115,29 @@ struct IO_ERROR // : std::exception
* @param aMsg is error text that will be streamed through wxString.Printf() * @param aMsg is error text that will be streamed through wxString.Printf()
* using the format string IO_FORMAT above. * using the format string IO_FORMAT above.
*/ */
IO_ERROR( const char* aThrowersFile, explicit IO_ERROR( const char* aThrowersFile,
const char* aThrowersLoc, const char* aThrowersLoc,
const wxString& aMsg ) const wxString& aMsg )
{ {
init( aThrowersFile, aThrowersLoc, aMsg ); init( aThrowersFile, aThrowersLoc, aMsg );
} }
#if !wxCHECK_VERSION(2, 9, 0) explicit IO_ERROR( const char* aThrowersFile,
// 2.9.0 and greater provide a wxString() constructor taking "const char*" whereas
// 2.8 did not. In 2.9.x this IO_ERROR() constructor uses that wxString( const char* )
// constructor making this here constructor ambiguous with the IO_ERROR()
// taking the wxString.
IO_ERROR( const char* aThrowersFile,
const char* aThrowersLoc, const char* aThrowersLoc,
const std::string& aMsg ) const std::string& aMsg )
{ {
init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg.c_str() ) ); init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg.c_str() ) );
} }
#endif
/** explicit IO_ERROR( const char* aThrowersFile,
* handles the case where _() is passed as aMsg. const char* aThrowersLoc,
*/ const char* aMsg )
IO_ERROR( const char* aThrowersFile, {
init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg ) );
}
/// handle the case where _() is passed as aMsg.
explicit IO_ERROR( const char* aThrowersFile,
const char* aThrowersLoc, const char* aThrowersLoc,
const wxChar* aMsg ) const wxChar* aMsg )
{ {
......
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
using namespace std; using namespace std;
typedef boost::ptr_map<std::string, wxZipEntry> MODULE_MAP; typedef boost::ptr_map<string, wxZipEntry> MODULE_MAP;
typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::iterator MODULE_ITER;
typedef MODULE_MAP::const_iterator MODULE_CITER; typedef MODULE_MAP::const_iterator MODULE_CITER;
/** /**
...@@ -166,11 +166,17 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ) ...@@ -166,11 +166,17 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )
{ {
if( !m_cache || m_lib_path != aLibraryPath ) if( !m_cache || m_lib_path != aLibraryPath )
{ {
//D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n", __func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );) // operator==( wxString, wxChar* ) does not exist, construct wxString once here.
const wxString kicad_mod( wxT( "kicad_mod" ) );
//D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n", __func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );)
delete m_cache; delete m_cache;
m_cache = new GH_CACHE(); m_cache = new GH_CACHE();
// INIT_LOGGER( "/tmp", "test.log" );
remote_get_zip( aLibraryPath ); remote_get_zip( aLibraryPath );
// UNINIT_LOGGER();
m_lib_path = aLibraryPath; m_lib_path = aLibraryPath;
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() ); wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
...@@ -182,11 +188,11 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ) ...@@ -182,11 +188,11 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )
while( ( entry = zis.GetNextEntry() ) != NULL ) while( ( entry = zis.GetNextEntry() ) != NULL )
{ {
wxFileName fn( entry->GetName() ); wxFileName fn( entry->GetName() ); // chop long name into parts
if( fn.GetExt() == wxT( "kicad_mod" ) ) if( fn.GetExt() == kicad_mod )
{ {
string fp_name = TO_UTF8( fn.GetName() ); string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path
m_cache->insert( fp_name, entry ); m_cache->insert( fp_name, entry );
} }
...@@ -253,9 +259,17 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) ...@@ -253,9 +259,17 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
// 4 lines, using SSL, top that. // 4 lines, using SSL, top that.
} }
catch( std::exception& e ) catch( boost::system::system_error& e )
{ {
THROW_IO_ERROR( e.what() ); // https "GET" has faild, report this to API caller.
wxString fmt( _( "Cannot GET zip: '%s'\nfor lib-path: '%s'.\nWhat: '%s'" ) );
string msg = StrPrintf( TO_UTF8( fmt ),
zip_url.c_str(),
TO_UTF8( aRepoURL ),
e.what() );
THROW_IO_ERROR( msg );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment