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

if https:// GET fails, report the URL

parent 44ca3530
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -115,31 +115,29 @@ struct IO_ERROR // : std::exception
     * @param aMsg is error text that will be streamed through wxString.Printf()
     *  using the format string IO_FORMAT above.
     */
    IO_ERROR( const char* aThrowersFile,
    explicit IO_ERROR( const char* aThrowersFile,
              const char* aThrowersLoc,
              const wxString& aMsg )
    {
        init( aThrowersFile, aThrowersLoc, aMsg );
    }

#if !wxCHECK_VERSION(2, 9, 0)
    // 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,
    explicit IO_ERROR( const char* aThrowersFile,
              const char* aThrowersLoc,
              const std::string& aMsg )
    {
        init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg.c_str() ) );
    }
#endif

    /**
     * handles the case where _() is passed as aMsg.
     */
    IO_ERROR( const char* aThrowersFile,
    explicit IO_ERROR( const char* aThrowersFile,
              const char* aThrowersLoc,
              const char* aMsg )
    {
        init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg ) );
    }

    /// handle the case where _() is passed as aMsg.
    explicit IO_ERROR( const char* aThrowersFile,
              const char* aThrowersLoc,
              const wxChar* aMsg )
    {
+23 −9
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@

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::const_iterator          MODULE_CITER;

@@ -166,11 +166,17 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )
{
    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;
        m_cache = new GH_CACHE();

        // INIT_LOGGER( "/tmp", "test.log" );
        remote_get_zip( aLibraryPath );
        // UNINIT_LOGGER();

        m_lib_path = aLibraryPath;

        wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
@@ -182,11 +188,11 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )

        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 );
            }
@@ -253,9 +259,17 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )

        // 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 );
    }
}