PageRenderTime 58ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/error.js

https://github.com/zippo445/nodegit
JavaScript | 62 lines | 37 code | 6 blank | 19 comment | 2 complexity | b25762a7056a2b0c63efdd00093328e5 MD5 | raw file
Possible License(s): AGPL-3.0
  1. var git = require('../'),
  2. util = require('util');
  3. /**
  4. * GitError constructor.
  5. *
  6. * @constructor
  7. * @param {String} [message = 'No message'] The error description. Set from giterr_last->message.
  8. * @param {Integer} [code = git.raw.Error.codes.GITERR_INVALID] The error code. Set from giterr_last->klass
  9. */
  10. var GitError = function(message, code) {
  11. Error.call(this);
  12. Error.captureStackTrace(this, exports.error);
  13. this.name = 'GitError';
  14. this.message = message || 'No message';
  15. this.code = code || git.raw.Error.codes.GITERR_INVALID;
  16. };
  17. util.inherits(GitError, Error);
  18. /**
  19. * Refer to vendor/libgit2/include/git2/errors.h for error code definitions.
  20. *
  21. * @readonly
  22. * @enum {Integer}
  23. */
  24. GitError.prototype.codes = {
  25. /** 0 */ GITERR_NOMEMORY: git.raw.Error.codes.GITERR_NOMEMORY,
  26. /** 1 */ GITERR_OS: git.raw.Error.codes.GITERR_OS,
  27. /** 2 */ GITERR_INVALID: git.raw.Error.codes.GITERR_INVALID,
  28. /** 3 */ GITERR_REFERENCE: git.raw.Error.codes.GITERR_REFERENCE,
  29. /** 4 */ GITERR_ZLIB: git.raw.Error.codes.GITERR_ZLIB,
  30. /** 5 */ GITERR_REPOSITORY: git.raw.Error.codes.GITERR_REPOSITORY,
  31. /** 6 */ GITERR_CONFIG: git.raw.Error.codes.GITERR_CONFIG,
  32. /** 7 */ GITERR_REGEX: git.raw.Error.codes.GITERR_REGEX,
  33. /** 8 */ GITERR_ODB: git.raw.Error.codes.GITERR_ODB,
  34. /** 9 */ GITERR_INDEX: git.raw.Error.codes.GITERR_INDEX,
  35. /** 10 */ GITERR_OBJECT: git.raw.Error.codes.GITERR_OBJECT,
  36. /** 11 */ GITERR_NET: git.raw.Error.codes.GITERR_NET,
  37. /** 12 */ GITERR_TAG: git.raw.Error.codes.GITERR_TAG,
  38. /** 13 */ GITERR_TREE: git.raw.Error.codes.GITERR_TREE
  39. };
  40. /**
  41. * Refer to vendor/libgit2/include/git2/errors.h for return code definitions.
  42. *
  43. * @readonly
  44. * @enum {Integer}
  45. */
  46. GitError.prototype.returnCodes = {
  47. /** 0 */ GIT_OK: git.raw.Error.returnCodes.GIT_OK,
  48. /** -1 */ GIT_ERROR: git.raw.Error.returnCodes.GIT_ERROR,
  49. /** -3 */ GIT_ENOTFOUND: git.raw.Error.returnCodes.GIT_ENOTFOUND,
  50. /** -4 */ GIT_EEXISTS: git.raw.Error.returnCodes.GIT_EEXISTS,
  51. /** -5 */ GIT_EAMBIGUOUS: git.raw.Error.returnCodes.GIT_EAMBIGUOUS,
  52. /** -6 */ GIT_EBUFS: git.raw.Error.returnCodes.GIT_EBUFS,
  53. /** -30 */ GIT_PASSTHROUGH: git.raw.Error.returnCodes.GIT_PASSTHROUGH,
  54. /** -31 */ GIT_ITEROVER: git.raw.Error.returnCodes.GIT_ITEROVER
  55. };
  56. exports.error = GitError;