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

Replace trivial uses of rethrow(exc) with rethrow() #873

Merged
merged 1 commit into from
Nov 1, 2018
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
4 changes: 2 additions & 2 deletions bin/gitmeta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function gitmeta(pkgs::Dict{String,Package})
if !updated
try LibGit2.GitObject(repo, git_commit_hash)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
@info "Updating $pkg from $(p.url)"
LibGit2.fetch(repo, remoteurl=p.url, refspecs=["+refs/*:refs/remotes/cache/*"])
end
Expand All @@ -94,7 +94,7 @@ function gitmeta(pkgs::Dict{String,Package})
git_commit = try LibGit2.GitObject(repo, git_commit_hash)
catch err
failed = true
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
@error("$pkg: git object $(v.sha1) could not be found")
end
failed && continue
Expand Down
6 changes: 3 additions & 3 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,22 @@ function update_registry(ctx)
try
GitTools.fetch(repo; refspecs=["+refs/heads/$branch:refs/remotes/origin/$branch"])
catch e
e isa PkgError || rethrow(e)
e isa PkgError || rethrow()
push!(errors, (reg, "failed to fetch from repo"))
@goto done
end
ff_succeeded = try
LibGit2.merge!(repo; branch="refs/remotes/origin/$branch", fastforward=true)
catch e
e isa LibGit2.GitError && e.code == LibGit2.Error.ENOTFOUND || rethrow(e)
e isa LibGit2.GitError && e.code == LibGit2.Error.ENOTFOUND || rethrow()
push!(errors, (reg, "branch origin/$branch not found"))
@goto done
end

if !ff_succeeded
try LibGit2.rebase!(repo, "origin/$branch")
catch e
e isa LibGit2.GitError || rethrow(e)
e isa LibGit2.GitError || rethrow()
push!(errors, (reg, "registry failed to rebase on origin/$branch"))
@goto done
end
Expand Down
2 changes: 1 addition & 1 deletion src/Display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const color_dark = :light_black
function git_file_stream(repo::LibGit2.GitRepo, spec::String; fakeit::Bool=false)::IO
blob = try LibGit2.GitBlob(repo, spec)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
fakeit && return devnull
end
iob = IOBuffer(LibGit2.content(blob))
Expand Down
4 changes: 2 additions & 2 deletions src/GitTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function clone(url, source_path; header=nothing, kwargs...)
return LibGit2.clone(url, source_path; callbacks=callbacks, kwargs...)
catch err
rm(source_path; force=true, recursive=true)
err isa LibGit2.GitError || rethrow(err)
err isa LibGit2.GitError || rethrow()
if (err.class == LibGit2.Error.Net && err.code == LibGit2.Error.EINVALIDSPEC) ||
(err.class == LibGit2.Error.Repository && err.code == LibGit2.Error.ENOTFOUND)
Pkg.Types.pkgerror("Git repository not found at '$(url)'")
Expand Down Expand Up @@ -131,7 +131,7 @@ function fetch(repo::LibGit2.GitRepo, remoteurl=nothing; header=nothing, kwargs.
try
return LibGit2.fetch(repo; remoteurl=remoteurl, callbacks=callbacks, kwargs...)
catch err
err isa LibGit2.GitError || rethrow(err)
err isa LibGit2.GitError || rethrow()
if (err.class == LibGit2.Error.Repository && err.code == LibGit2.Error.ERROR)
Pkg.Types.pkgerror("Git repository not found at '$(remoteurl)'")
else
Expand Down
2 changes: 1 addition & 1 deletion src/GraphType.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ function deep_clean!(graph::Graph)
try
propagate_constraints!(graph, Set{Int}([p0]), log_events = false)
catch err
err isa ResolverError || rethrow(err)
err isa ResolverError || rethrow()
gconstr_msk[p0][v0] = false
end
pop_snapshot!(graph)
Expand Down
10 changes: 5 additions & 5 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ function install_archive(
try
run(cmd, (devnull, devnull, devnull))
catch e
e isa InterruptException && rethrow(e)
e isa InterruptException && rethrow()
url_success = false
end
url_success || continue
Expand All @@ -473,7 +473,7 @@ function install_archive(
try
run(cmd, (devnull, devnull, devnull))
catch e
e isa InterruptException && rethrow(e)
e isa InterruptException && rethrow()
@warn "failed to extract archive downloaded from $(archive_url)"
url_success = false
end
Expand Down Expand Up @@ -518,7 +518,7 @@ function install_git(
end
break # object was found, we can stop
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
end
GitTools.fetch(repo, url, refspecs=refspecs, credentials=creds)
end
Expand All @@ -527,7 +527,7 @@ function install_git(
tree = try
LibGit2.GitObject(repo, git_hash)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
error("$name: git object $(string(hash)) could not be found")
end
tree isa LibGit2.GitTree ||
Expand Down Expand Up @@ -667,7 +667,7 @@ function find_stdlib_deps(ctx::Context, path::String)
endswith(file, ".jl") || continue
filecontent = try read(joinpath(root, file), String)
catch e
e isa SystemError || rethrow(e)
e isa SystemError || rethrow()
""
end
for ((uuid, stdlib), r) in zip(ctx.stdlibs, regexps)
Expand Down
2 changes: 1 addition & 1 deletion src/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function do_cmd(repl::REPL.AbstractREPL, input::String; do_rethrow=false)
end
catch err
if do_rethrow
rethrow(err)
rethrow()
end
if err isa PkgError || err isa ResolverError
Base.display_error(repl.t.err_stream, ErrorException(sprint(showerror, err)), Ptr{Nothing}[])
Expand Down
4 changes: 2 additions & 2 deletions src/Resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function sanity_check(graph::Graph, sources::Set{UUID} = Set{UUID}(), verbose::B
try
simplify_graph_soft!(graph, Set{Int}([p0]), log_events = false)
catch err
isa(err, ResolverError) || rethrow(err)
isa(err, ResolverError) || rethrow()
@goto done
end

Expand Down Expand Up @@ -220,7 +220,7 @@ function greedysolver(graph::Graph)
try
simplify_graph_soft!(graph, req_inds, log_events = false)
catch err
err isa ResolverError || rethrow(err)
err isa ResolverError || rethrow()
pop_snapshot!(graph)
return (false, Int[])
end
Expand Down
8 changes: 4 additions & 4 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ end
function read_manifest(file::String)
try isfile(file) ? open(read_manifest, file) : read_manifest(devnull)
catch err
err isa ErrorException && startswith(err.msg, "ambiguious dependency") || rethrow(err)
err isa ErrorException && startswith(err.msg, "ambiguious dependency") || rethrow()
err.msg *= "In manifest file: $file"
rethrow(err)
end
Expand Down Expand Up @@ -755,18 +755,18 @@ function get_object_branch(repo, rev, creds)
gitobject = LibGit2.GitObject(repo, "remotes/cache/heads/" * rev)
isbranch = true
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
end
if gitobject == nothing
try
gitobject = LibGit2.GitObject(repo, rev)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
GitTools.fetch(repo; refspecs=refspecs, credentials=creds)
try
gitobject = LibGit2.GitObject(repo, rev)
catch err
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err)
err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow()
pkgerror("git object $(rev) could not be found")
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/resolve/MaxSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function try_simplify_graph_soft!(graph, sources)
try
simplify_graph_soft!(graph, sources, log_events = false)
catch err
err isa ResolverError || rethrow(err)
err isa ResolverError || rethrow()
return false
end
return true
Expand All @@ -373,7 +373,7 @@ function converge!(graph::Graph, msgs::Messages, strace::SolutionTrace, perm::No
try
maxdiff = iterate!(graph, msgs, perm)
catch err
err isa UnsatError || rethrow(err)
err isa UnsatError || rethrow()
if is_best_sofar
p0 = err.p0
s0 = findlast(graph.gconstr[p0])
Expand Down