You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MissingObjectException.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2009, Google Inc.
  3. * Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
  4. * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
  5. * Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
  6. *
  7. * This program and the accompanying materials are made available under the
  8. * terms of the Eclipse Distribution License v. 1.0 which is available at
  9. * https://www.eclipse.org/org/documents/edl-v10.php.
  10. *
  11. * SPDX-License-Identifier: BSD-3-Clause
  12. */
  13. package org.eclipse.jgit.errors;
  14. import java.io.IOException;
  15. import java.text.MessageFormat;
  16. import org.eclipse.jgit.internal.JGitText;
  17. import org.eclipse.jgit.lib.AbbreviatedObjectId;
  18. import org.eclipse.jgit.lib.Constants;
  19. import org.eclipse.jgit.lib.ObjectId;
  20. /**
  21. * An expected object is missing.
  22. */
  23. public class MissingObjectException extends IOException {
  24. private static final long serialVersionUID = 1L;
  25. private final ObjectId missing;
  26. /**
  27. * Construct a MissingObjectException for the specified object id.
  28. * Expected type is reported to simplify tracking down the problem.
  29. *
  30. * @param id SHA-1
  31. * @param type object type
  32. */
  33. public MissingObjectException(ObjectId id, String type) {
  34. super(MessageFormat.format(JGitText.get().missingObject, type, id.name()));
  35. missing = id.copy();
  36. }
  37. /**
  38. * Construct a MissingObjectException for the specified object id.
  39. * Expected type is reported to simplify tracking down the problem.
  40. *
  41. * @param id SHA-1
  42. * @param type object type
  43. */
  44. public MissingObjectException(ObjectId id, int type) {
  45. this(id, Constants.typeString(type));
  46. }
  47. /**
  48. * Construct a MissingObjectException for the specified object id. Expected
  49. * type is reported to simplify tracking down the problem.
  50. *
  51. * @param id
  52. * SHA-1
  53. * @param type
  54. * object type
  55. */
  56. public MissingObjectException(AbbreviatedObjectId id, int type) {
  57. super(MessageFormat.format(JGitText.get().missingObject, Constants
  58. .typeString(type), id.name()));
  59. missing = null;
  60. }
  61. /**
  62. * Get the ObjectId that was not found
  63. *
  64. * @return the ObjectId that was not found
  65. */
  66. public ObjectId getObjectId() {
  67. return missing;
  68. }
  69. }