InstantiateFromURL.jl
InstantiateFromURL.jl copied to clipboard
More graceful failure for bad sha or tag
The error returned is raw
julia> activate_github("arnavs/InstantiationTest", sha="madeupgarbage")
Downloading arnavs/InstantiationTest-madeupgarbage → C:\Users\jlperla\Documents\.projects
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."
At line:5 char:1
+ $webclient.DownloadFile("https://github.com/arnavs/InstantiationTest/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
ERROR: failed process: Process(`powershell -NoProfile -Command '[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.SecurityProtocolType]::Tls12;
$webclient = (New-Object System.Net.Webclient);
$webclient.Headers.Add("user-agent", "BinaryProvider.jl (https://github.com/JuliaPackaging/BinaryProvider.jl)");
$webclient.DownloadFile("https://github.com/arnavs/InstantiationTest/archive/madeupgarbage.tar.gz", "C:\Users\jlperla\AppData\Local\Temp\InstantiationTest-madeupgarbage.tar.gz")
'`, ProcessExited(1)) [1]
Stacktrace:
[1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42
[2] pipeline_error at .\process.jl:695 [inlined]
[3] #run#505(::Bool, ::Function, ::Cmd) at .\process.jl:653
[4] run(::Cmd) at .\process.jl:651
[5] #activate_github#1(::Nothing, ::String, ::Bool, ::Function, ::String) at C:\Users\jlperla\.julia\packages\InstantiateFromURL\YX25j\src\activate.jl:28
[6] (::getfield(InstantiateFromURL, Symbol("#kw##activate_github")))(::NamedTuple{(:sha,),Tuple{String}}, ::typeof(activate_github), ::String) at .\none:0
[7] top-level scope at none:0
Not essential to be fixed immediately, but consider catching this sort of error and raising a more meaningful exception
Yeah. Naive way to do it would just be to wrap the gen_download_cmd in something that says "bad download." So we don't need to worry about malformed URLs vs. permissions to access the link vs. other things.