RefAlreadyExistsException.java

  1. /*
  2.  * Copyright (C) 2010, 2020 Mathias Kinzler <mathias.kinzler@sap.com> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */
  10. package org.eclipse.jgit.api.errors;

  11. import org.eclipse.jgit.annotations.Nullable;
  12. import org.eclipse.jgit.lib.RefUpdate;

  13. /**
  14.  * Thrown when trying to create a {@link org.eclipse.jgit.lib.Ref} with the same
  15.  * name as an existing one
  16.  */
  17. public class RefAlreadyExistsException extends GitAPIException {
  18.     private static final long serialVersionUID = 1L;

  19.     private final RefUpdate.Result updateResult;

  20.     /**
  21.      * Creates a new instance with the given message.
  22.      *
  23.      * @param message
  24.      *            error message
  25.      */
  26.     public RefAlreadyExistsException(String message) {
  27.         this(message, null);
  28.     }

  29.     /**
  30.      * Constructor for RefAlreadyExistsException
  31.      *
  32.      * @param message
  33.      *            error message
  34.      * @param updateResult
  35.      *            that caused the exception; may be {@code null}
  36.      * @since 5.11
  37.      */
  38.     public RefAlreadyExistsException(String message,
  39.             @Nullable RefUpdate.Result updateResult) {
  40.         super(message);
  41.         this.updateResult = updateResult;
  42.     }

  43.     /**
  44.      * Retrieves the {@link org.eclipse.jgit.lib.RefUpdate.Result
  45.      * RefUpdate.Result} that caused the exception.
  46.      *
  47.      * @return the {@link org.eclipse.jgit.lib.RefUpdate.Result
  48.      *         RefUpdate.Result} or {@code null} if unknown
  49.      * @since 5.11
  50.      */
  51.     @Nullable
  52.     public RefUpdate.Result getUpdateResult() {
  53.         return updateResult;
  54.     }
  55. }