Functions
2.1 Annotated Commit
2.2 Blame
2.3 Blob
2.4 Branch
2.5 Buffer
2.6 Checkout
2.7 Cherrypick
2.8 Clone
2.9 Commit
2.10 Config
2.11 Credentials
2.12 Describe
2.13 Diff
2.14 Fetch
2.15 Filter
2.16 Errors
2.17 Graph
2.18 Ignore
2.19 Index
2.20 Indexer
2.21 Global
2.22 Merge
2.23 Message
2.24 Note
2.25 Object
2.26 Object Database
2.27 Oid
2.28 Oid Array
2.29 Packbuilder
2.30 Patch
2.31 Pathspec
2.32 Proxy
2.33 Push
2.34 Rebase
2.35 Refdb
2.36 Reference
2.37 Reflog
2.38 Refspec
2.39 Remote
2.40 Repository
2.41 Reset
2.42 Revert
2.43 Revparse
2.44 Revwalk
2.45 Signature
2.46 Stash
2.47 Status
2.48 Strarray
2.49 Submodule
2.50 Tag
2.51 Tree
2.52 Treebuilder
On this page:
giterr_  clear
giterr_  last
giterr_  set_  oom
giterr_  set_  str
7.7

2.16 Errors

 (require libgit2/include/errors) package: libgit2

procedure

(giterr_clear)  void?

Clear the last library error that occurred for this thread.

procedure

(giterr_last)  error?

Return the last git_error object that was generated for the current thread or NULL if no error has occurred.

procedure

(giterr_set_oom)  void?

Set the error message to a special value for memory allocation failure.

The normal giterr_set_str() function attempts to strdup() the string that is passed in. This is not a good idea when the error in question is a memory allocation failure. That circumstance has a special setter function that sets the error string to a known and statically allocated internal value.

procedure

(giterr_set_str error_class message)  void?

  error_class : integer?
  message : string?
Set the error message string for this thread.

This function is public so that custom ODB backends and the like can relay an error message through libgit2. Most regular users of libgit2 will never need to call this function – actually, calling it in most circumstances (for example, calling from within a callback function) will just end up having the value overwritten by libgit2 internals.

This error message is stored in thread-local storage and only applies to the particular thread that this libgit2 call is made from.