From 4e03373c947eef1ce56ef76fcf3465c82d433118 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Tue, 11 Apr 2017 00:58:36 -0400 Subject: [PATCH] Make libgit2 print repo path on error context-free error messages are ... not helpful --- base/libgit2/error.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/base/libgit2/error.jl b/base/libgit2/error.jl index 8e91bec65821c..12d175ba5cff1 100644 --- a/base/libgit2/error.jl +++ b/base/libgit2/error.jl @@ -83,9 +83,12 @@ function last_error() return (err_class, err_msg) end -function GitError(code::Integer) +function GitError(code::Integer; path = "") err_code = Code[code][] err_class, err_msg = last_error() + + length(path) > 0 && (err_msg = err_msg * "\n in path: $path") + return GitError(err_class, err_code, err_msg) end @@ -96,7 +99,7 @@ macro check(git_func) local err::Cint err = $(esc(git_func::Expr)) if err < 0 - throw(Error.GitError(err)) + throw(Error.GitError(err; path = gitdir($(esc(:repo))))) end err end