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

JuliaLang / julia / #37650

12 Oct 2023 03:02PM UTC coverage: 85.263% (-2.3%) from 87.56%
#37650

push

local

web-flow
Revert "Reinstate load-time Pkg.precompile" (#51675)

1 of 1 new or added line in 1 file covered. (100.0%)

70225 of 82363 relevant lines covered (85.26%)

12218375.87 hits per line

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

85.0
/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
            TIMEOUT         = Cint(-37)) # The operation timed out
38

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

77
struct ErrorStruct
78
    message::Ptr{UInt8}
79
    class::Cint
80
end
81

82
struct GitError <: Exception
83
    class::Class
6✔
84
    code::Code
85
    msg::String
86
end
87
Base.show(io::IO, err::GitError) = print(io, "GitError(Code:$(err.code), Class:$(err.class), $(err.msg))")
×
88

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

103
GitError(err_code::Integer) = GitError(Code(err_code))
6✔
104
function GitError(err_code::Code)
6✔
105
    err_class, err_msg = last_error()
6✔
106
    return GitError(err_class, err_code, err_msg)
6✔
107
end
108

109
end # Error module
110

111
macro check(git_func)
112
    quote
113
        err = Cint($(esc(git_func::Expr)))
21✔
114
        if err < 0
21✔
115
            throw(Error.GitError(err))
3✔
116
        end
117
        err
18✔
118
    end
119
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