• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37620

14 Sep 2023 12:24AM UTC coverage: 85.982% (-0.7%) from 86.645%
#37620

push

local

web-flow
EA: some noncritical updates on EA (#51292)

9 of 9 new or added lines in 3 files covered. (100.0%)

73376 of 85339 relevant lines covered (85.98%)

12810329.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/stdlib/LibGit2/src/error.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
module Error
4

5
import ..LibGit2: ensure_initialized
6
using LibGit2_jll
7

8
export GitError
9

10
@enum(Code, GIT_OK          = Cint(0),   # no error
11
            ERROR           = Cint(-01), # generic error
12
            ENOTFOUND       = Cint(-03), # requested object could not be found
13
            EEXISTS         = Cint(-04), # object exits preventing op
14
            EAMBIGUOUS      = Cint(-05), # more than one object matches
15
            EBUFS           = Cint(-06), # output buffer too small to hold data
16
            EUSER           = Cint(-07), # user callback generated error
17
            EBAREREPO       = Cint(-08), # operation not allowed on bare repo
18
            EUNBORNBRANCH   = Cint(-09), # HEAD refers to branch with 0 commits
19
            EUNMERGED       = Cint(-10), # merge in progress prevented op
20
            ENONFASTFORWARD = Cint(-11), # ref not fast-forwardable
21
            EINVALIDSPEC    = Cint(-12), # name / ref not in valid format
22
            EMERGECONFLICT  = Cint(-13), # merge conflict prevented op
23
            ELOCKED         = Cint(-14), # lock file prevented op
24
            EMODIFIED       = Cint(-15), # ref value does not match expected
25
            EAUTH           = Cint(-16), # authentication error
26
            ECERTIFICATE    = Cint(-17), # server certificate is invalid
27
            EAPPLIED        = Cint(-18), # patch/merge has already been applied
28
            EPEEL           = Cint(-19), # the requested peel operation is not possible
29
            EEOF            = Cint(-20), # unexpected EOF
30
            PASSTHROUGH     = Cint(-30), # internal only
31
            ITEROVER        = Cint(-31), # signals end of iteration
32
            RETRY           = Cint(-32), # internal only
33
            EMISMATCH       = Cint(-33), # hashsum mismatch in object
34
            EINDEXDIRTY     = Cint(-34), # unsaved changes in the index would be overwritten
35
            EAPPLYFAIL      = Cint(-35), # patch application failed
36
            EOWNER          = Cint(-36)) # the object is not owned by the current user
37

38
@enum(Class, None,
39
             NoMemory,
40
             OS,
41
             Invalid,
42
             Reference,
43
             Zlib,
44
             Repository,
45
             Config,
46
             Regex,
47
             Odb,
48
             Index,
49
             Object,
50
             Net,
51
             Tag,
52
             Tree,
53
             Indexer,
54
             SSL,
55
             Submodule,
56
             Thread,
57
             Stash,
58
             Checkout,
59
             FetchHead,
60
             Merge,
61
             SSH,
62
             Filter,
63
             Revert,
64
             Callback,
65
             CherryPick,
66
             Describe,
67
             Rebase,
68
             Filesystem,
69
             Patch,
70
             WorkTree,
71
             SHA1,
72
             HTTP)
73

74
struct ErrorStruct
75
    message::Ptr{UInt8}
76
    class::Cint
77
end
78

79
struct GitError <: Exception
80
    class::Class
56✔
81
    code::Code
82
    msg::String
83
end
84
Base.show(io::IO, err::GitError) = print(io, "GitError(Code:$(err.code), Class:$(err.class), $(err.msg))")
1✔
85

86
function last_error()
×
87
    ensure_initialized()
42✔
88
    err = ccall((:giterr_last, libgit2), Ptr{ErrorStruct}, ())
42✔
89
    if err != C_NULL
42✔
90
        err_obj   = unsafe_load(err)
42✔
91
        err_class = Class(err_obj.class)
42✔
92
        err_msg   = unsafe_string(err_obj.message)
42✔
93
    else
94
        err_class = Class(0)
×
95
        err_msg = "No errors"
×
96
    end
97
    return (err_class, err_msg)
42✔
98
end
99

100
GitError(err_code::Integer) = GitError(Code(err_code))
42✔
101
function GitError(err_code::Code)
×
102
    err_class, err_msg = last_error()
42✔
103
    return GitError(err_class, err_code, err_msg)
42✔
104
end
105

106
end # Error module
107

108
macro check(git_func)
2✔
109
    quote
2✔
110
        err = Cint($(esc(git_func::Expr)))
1,391✔
111
        if err < 0
1,311✔
112
            throw(Error.GitError(err))
41✔
113
        end
114
        err
339✔
115
    end
116
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc