Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix throwing of Pkg errors, add error-condition tests and fixes #13420

Merged
merged 4 commits into from
Oct 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@ function cd(f::Function, args...; kws...)
!haskey(ENV,"JULIA_PKGDIR") ? init() :
throw(PkgError("Package metadata directory $metadata_dir doesn't exist; run Pkg.init() to initialize it."))
end
try
Base.cd(()->f(args...; kws...), dir)
catch err
if isa(err, PkgError)
print_with_color(:red, "ERROR: $(err.msg)")
else
throw(err)
end
end
Base.cd(()->f(args...; kws...), dir)
end

function init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH)
Expand Down
6 changes: 3 additions & 3 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ pin(pkg::AbstractString) = pin(pkg, "")

function pin(pkg::AbstractString, ver::VersionNumber)
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo"))
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be pinned – not an installed package".tmp))
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be pinned – not an installed package"))
avail = Read.available(pkg)
isempty(avail) && throw(PkgError("$pkg cannot be pinned – not a registered package".tmp))
isempty(avail) && throw(PkgError("$pkg cannot be pinned – not a registered package"))
haskey(avail,ver) || throw(PkgError("$pkg – $ver is not a registered version"))
pin(pkg, avail[ver].sha1)
end
Expand Down Expand Up @@ -475,7 +475,7 @@ function resolve(
for pkg in keys(reqs)
if !haskey(deps,pkg)
if "julia" in conflicts[pkg]
throw(PkgError("$pkg can't be installed because it has no versions that support ", VERSION, " of julia. " *
throw(PkgError("$pkg can't be installed because it has no versions that support $VERSION of julia. " *
"You may need to update METADATA by running `Pkg.update()`"))
else
sconflicts = join(conflicts[pkg], ", ", " and ")
Expand Down
2 changes: 2 additions & 0 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ eval(Expr(:function, Expr(:call, :test_inline_2),

try
eval(:(test_inline_1()))
error("unexpected")
catch err
lkup = get_bt_frame(:test_inline_1, catch_backtrace())
if is(lkup, nothing)
Expand All @@ -51,6 +52,7 @@ catch err
end
try
eval(:(test_inline_2()))
error("unexpected")
catch err
lkup = get_bt_frame(:test_inline_2, catch_backtrace())
if is(lkup, nothing)
Expand Down
1 change: 1 addition & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ let deepthought(x, y) = 42
try
@assert 1 == 2 string("the answer to the ultimate question: ",
deepthought(6, 9))
error("unexpected")
catch ex
@test isa(ex, AssertionError)
@test ex.msg == "the answer to the ultimate question: 42"
Expand Down
2 changes: 2 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ try
@async error(i)
end
end
error("unexpected")
catch ex
@test typeof(ex) == CompositeException
@test length(ex) == 5
Expand All @@ -394,6 +395,7 @@ end

try
remotecall_fetch(()->throw(ErrorException("foobar")), id_other)
error("unexpected")
catch ex
@test typeof(ex) == RemoteException
@test typeof(ex.captured) == CapturedException
Expand Down
Loading