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.

Die.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2009, Google Inc.
  3. * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
  4. *
  5. * This program and the accompanying materials are made available under the
  6. * terms of the Eclipse Distribution License v. 1.0 which is available at
  7. * https://www.eclipse.org/org/documents/edl-v10.php.
  8. *
  9. * SPDX-License-Identifier: BSD-3-Clause
  10. */
  11. package org.eclipse.jgit.pgm;
  12. /**
  13. * Indicates a {@link org.eclipse.jgit.pgm.TextBuiltin} implementation has
  14. * failed during execution.
  15. * <p>
  16. * Typically the stack trace for a Die exception is not shown to the user as it
  17. * may indicate a simple error condition that the end-user can fix on their own,
  18. * without needing a screen of Java stack frames.
  19. */
  20. public class Die extends RuntimeException {
  21. private static final long serialVersionUID = 1L;
  22. private boolean aborted;
  23. /**
  24. * Construct a new message explaining what has gone wrong.
  25. *
  26. * @param why
  27. * the message to show to the end-user.
  28. */
  29. public Die(String why) {
  30. super(why);
  31. }
  32. /**
  33. * Construct a new message explaining what has gone wrong.
  34. *
  35. * @param why
  36. * the message to show to the end-user.
  37. * @param cause
  38. * why the command has failed.
  39. */
  40. public Die(String why, Throwable cause) {
  41. super(why, cause);
  42. }
  43. /**
  44. * Construct a new exception reflecting the fact that the
  45. * command execution has been aborted before running.
  46. *
  47. * @param aborted boolean indicating the fact the execution has been aborted
  48. * @since 3.4
  49. */
  50. public Die(boolean aborted) {
  51. this(aborted, null);
  52. }
  53. /**
  54. * Construct a new exception reflecting the fact that the command execution
  55. * has been aborted before running.
  56. *
  57. * @param aborted
  58. * boolean indicating the fact the execution has been aborted
  59. * @param cause
  60. * can be null
  61. * @since 4.2
  62. */
  63. public Die(boolean aborted, Throwable cause) {
  64. super(cause != null ? cause.getMessage() : null, cause);
  65. this.aborted = aborted;
  66. }
  67. /**
  68. * Check if this exception should cause the execution to be aborted.
  69. *
  70. * @return boolean indicating that the execution should be aborted
  71. * @since 3.4
  72. */
  73. public boolean isAborted() {
  74. return aborted;
  75. }
  76. }