View Javadoc
1   /*
2    * Copyright (C) 2009-2010, Google Inc. 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  
11  package org.eclipse.jgit.errors;
12  
13  import java.io.File;
14  import java.text.MessageFormat;
15  
16  import org.eclipse.jgit.internal.JGitText;
17  
18  /**
19   * Indicates a local repository does not exist.
20   */
21  public class RepositoryNotFoundException extends TransportException {
22  	private static final long serialVersionUID = 1L;
23  
24  	/**
25  	 * Constructs an exception indicating a local repository does not exist.
26  	 *
27  	 * @param location
28  	 *            description of the repository not found, usually file path.
29  	 */
30  	public RepositoryNotFoundException(File location) {
31  		this(location.getPath());
32  	}
33  
34  	/**
35  	 * Constructs an exception indicating a local repository does not exist.
36  	 *
37  	 * @param location
38  	 *            description of the repository not found, usually file path.
39  	 * @param why
40  	 *            why the repository does not exist.
41  	 */
42  	public RepositoryNotFoundException(File location, Throwable why) {
43  		this(location.getPath(), why);
44  	}
45  
46  	/**
47  	 * Constructs an exception indicating a local repository does not exist.
48  	 *
49  	 * @param location
50  	 *            description of the repository not found, usually file path.
51  	 */
52  	public RepositoryNotFoundException(String location) {
53  		super(message(location));
54  	}
55  
56  	/**
57  	 * Constructs an exception indicating a local repository does not exist.
58  	 *
59  	 * @param location
60  	 *            description of the repository not found, usually file path.
61  	 * @param why
62  	 *            why the repository does not exist.
63  	 */
64  	public RepositoryNotFoundException(String location, Throwable why) {
65  		super(message(location), why);
66  	}
67  
68  	private static String message(String location) {
69  		return MessageFormat.format(JGitText.get().repositoryNotFound, location);
70  	}
71  }