Pcbnew: bug fix and minor changes in github plugin. (fixes lp:1484331)
* Catch all unhandled exceptions derived from std::exception() class in KICAD_PLUGIN::get_remote_zip() to prevent KiCad from crashing when exceptions are thrown from the C++ standard library. * Make boost::system::system_error() catch const and and improve comments about avhttp library usage in KICAD_PLUGIN::get_remote_zip(). Thanks to Dick Hollenbeck for these improvements.
This commit is contained in:
parent
61f4f1ca9d
commit
7ba02bad7c
|
@ -495,17 +495,21 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||||
zip_url += "/zip/master";
|
zip_url += "/zip/master";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This is the generic code path for any server which can serve
|
// This is the generic code path for any server which can serve
|
||||||
// up zip files which is not github.com. The schemes tested include:
|
// up zip files. The schemes tested include: http and https.
|
||||||
// http and https, I don't know what the avhttp library supports beyond that.
|
// (I don't know what the avhttp library supports beyond that.)
|
||||||
|
|
||||||
// zip_url goal: "<scheme>://<server>[:<port>]/<path>"
|
// zip_url goal: "<scheme>://<server>[:<port>]/<path>"
|
||||||
|
|
||||||
// Remember that <scheme>, <server>, <port> if present, and <path> all came
|
// Remember that <scheme>, <server>, <port> if present, and <path> all came
|
||||||
// from the lib_path in the fp-lib-table row.
|
// from the lib_path in the fp-lib-table row.
|
||||||
|
|
||||||
|
// This code path is used with the nginx proxy setup, but is useful
|
||||||
|
// beyond that.
|
||||||
|
|
||||||
zip_url += repo.GetServer();
|
zip_url += repo.GetServer();
|
||||||
|
|
||||||
if( repo.HasPort() )
|
if( repo.HasPort() )
|
||||||
|
@ -561,7 +565,7 @@ 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( boost::system::system_error& e )
|
catch( const boost::system::system_error& e )
|
||||||
{
|
{
|
||||||
// https "GET" has faild, report this to API caller.
|
// https "GET" has faild, report this to API caller.
|
||||||
static const char errorcmd[] = "http GET command failed"; // Do not translate this message
|
static const char errorcmd[] = "http GET command failed"; // Do not translate this message
|
||||||
|
@ -579,8 +583,16 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
THROW_IO_ERROR( msg );
|
||||||
}
|
}
|
||||||
|
catch( const exception& exc )
|
||||||
|
{
|
||||||
|
UTF8 error( _( "Exception '%s' in avhttp while open()-ing URI:'%s'" ) );
|
||||||
|
|
||||||
|
string msg = StrPrintf( error.c_str(), exc.what(), zip_url.c_str() );
|
||||||
|
THROW_IO_ERROR( msg );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This GITHUB_GETLIBLIST method should not be here, but in github_getliblist.cpp !
|
// This GITHUB_GETLIBLIST method should not be here, but in github_getliblist.cpp !
|
||||||
// However it is here just because we need to include <avhttp.hpp> to compile it.
|
// However it is here just because we need to include <avhttp.hpp> to compile it.
|
||||||
// and when we include avhttp in two .cpp files, the link fails because it detects duplicate
|
// and when we include avhttp in two .cpp files, the link fails because it detects duplicate
|
||||||
|
|
Loading…
Reference in New Issue