RepositoryNotFoundException.java

  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. package org.eclipse.jgit.errors;

  11. import java.io.File;
  12. import java.text.MessageFormat;

  13. import org.eclipse.jgit.internal.JGitText;

  14. /**
  15.  * Indicates a local repository does not exist.
  16.  */
  17. public class RepositoryNotFoundException extends TransportException {
  18.     private static final long serialVersionUID = 1L;

  19.     /**
  20.      * Constructs an exception indicating a local repository does not exist.
  21.      *
  22.      * @param location
  23.      *            description of the repository not found, usually file path.
  24.      */
  25.     public RepositoryNotFoundException(File location) {
  26.         this(location.getPath());
  27.     }

  28.     /**
  29.      * Constructs an exception indicating a local repository does not exist.
  30.      *
  31.      * @param location
  32.      *            description of the repository not found, usually file path.
  33.      * @param why
  34.      *            why the repository does not exist.
  35.      */
  36.     public RepositoryNotFoundException(File location, Throwable why) {
  37.         this(location.getPath(), why);
  38.     }

  39.     /**
  40.      * Constructs an exception indicating a local repository does not exist.
  41.      *
  42.      * @param location
  43.      *            description of the repository not found, usually file path.
  44.      */
  45.     public RepositoryNotFoundException(String location) {
  46.         super(message(location));
  47.     }

  48.     /**
  49.      * Constructs an exception indicating a local repository does not exist.
  50.      *
  51.      * @param location
  52.      *            description of the repository not found, usually file path.
  53.      * @param why
  54.      *            why the repository does not exist.
  55.      */
  56.     public RepositoryNotFoundException(String location, Throwable why) {
  57.         super(message(location), why);
  58.     }

  59.     private static String message(String location) {
  60.         return MessageFormat.format(JGitText.get().repositoryNotFound, location);
  61.     }
  62. }