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
12 import org.eclipse.jgit.annotations.Nullable;
13 import org.eclipse.jgit.lib.RefUpdate;
14
15 /**
16 * Thrown when trying to create a {@link org.eclipse.jgit.lib.Ref} with the same
17 * name as an existing one
18 */
19 public class RefAlreadyExistsException extends GitAPIException {
20 private static final long serialVersionUID = 1L;
21
22 private final RefUpdate.Result updateResult;
23
24 /**
25 * Creates a new instance with the given message.
26 *
27 * @param message
28 * error message
29 */
30 public RefAlreadyExistsException(String message) {
31 this(message, null);
32 }
33
34 /**
35 * Constructor for RefAlreadyExistsException
36 *
37 * @param message
38 * error message
39 * @param updateResult
40 * that caused the exception; may be {@code null}
41 * @since 5.11
42 */
43 public RefAlreadyExistsException(String message,
44 @Nullable RefUpdate.Result updateResult) {
45 super(message);
46 this.updateResult = updateResult;
47 }
48
49 /**
50 * Retrieves the {@link org.eclipse.jgit.lib.RefUpdate.Result
51 * RefUpdate.Result} that caused the exception.
52 *
53 * @return the {@link org.eclipse.jgit.lib.RefUpdate.Result
54 * RefUpdate.Result} or {@code null} if unknown
55 * @since 5.11
56 */
57 @Nullable
58 public RefUpdate.Result getUpdateResult() {
59 return updateResult;
60 }
61 }