PackInvalidException.java

  1. /*
  2.  * Copyright (C) 2009, 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.io.IOException;
  13. import java.text.MessageFormat;

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

  15. /**
  16.  * Thrown when a Pack previously failed and is known to be unusable
  17.  */
  18. public class PackInvalidException extends IOException {
  19.     private static final long serialVersionUID = 1L;

  20.     /**
  21.      * Construct a pack invalid error.
  22.      *
  23.      * @param path
  24.      *            path of the invalid pack file.
  25.      * @deprecated Use {@link #PackInvalidException(File, Throwable)}.
  26.      */
  27.     @Deprecated
  28.     public PackInvalidException(File path) {
  29.         this(path, null);
  30.     }

  31.     /**
  32.      * Construct a pack invalid error with cause.
  33.      *
  34.      * @param path
  35.      *            path of the invalid pack file.
  36.      * @param cause
  37.      *            cause of the pack file becoming invalid.
  38.      * @since 4.5.7
  39.      */
  40.     public PackInvalidException(File path, Throwable cause) {
  41.         this(path.getAbsolutePath(), cause);
  42.     }

  43.     /**
  44.      * Construct a pack invalid error.
  45.      *
  46.      * @param path
  47.      *            path of the invalid pack file.
  48.      * @deprecated Use {@link #PackInvalidException(String, Throwable)}.
  49.      */
  50.     @Deprecated
  51.     public PackInvalidException(String path) {
  52.         this(path, null);
  53.     }

  54.     /**
  55.      * Construct a pack invalid error with cause.
  56.      *
  57.      * @param path
  58.      *            path of the invalid pack file.
  59.      * @param cause
  60.      *            cause of the pack file becoming invalid.
  61.      * @since 4.5.7
  62.      */
  63.     public PackInvalidException(String path, Throwable cause) {
  64.         super(MessageFormat.format(JGitText.get().packFileInvalid, path), cause);
  65.     }
  66. }