Skip to content

Commit

Permalink
Fix stacktrace warning (hexpm#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj authored Mar 1, 2020
1 parent a393cef commit 513312b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/hex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ defmodule Hex do
def enum_split_with(enum, fun), do: Enum.split_with(enum, fun)
end

defmacro stacktrace() do
if Version.compare(System.version(), "1.7.0") == :lt do
quote do: System.stacktrace()
else
quote do: __STACKTRACE__
end
end

def file_lstat(path, opts \\ []) do
opts = Keyword.put_new(opts, :time, :universal)

Expand Down
3 changes: 2 additions & 1 deletion lib/hex/scm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ defmodule Hex.SCM do
Hex.unpack_tar!(path, dest)
rescue
exception ->
stacktrace = System.stacktrace()
require Hex
stacktrace = Hex.stacktrace()
File.rm(path)
reraise(exception, stacktrace)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/mix/tasks/hex.publish.ex
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ defmodule Mix.Tasks.Hex.Publish do
Mix.Task.run("docs", ["--canonical", canonical])
rescue
ex in [Mix.NoTaskError] ->
stacktrace = System.stacktrace()
require Hex
stacktrace = Hex.stacktrace()

Mix.shell().error("""
Publication failed because the "docs" task is unavailable. You may resolve this by:
Expand Down

0 comments on commit 513312b

Please sign in to comment.