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 11 package org.eclipse.jgit.errors; 12 13 import java.io.File; 14 import java.io.IOException; 15 import java.text.MessageFormat; 16 17 import org.eclipse.jgit.internal.JGitText; 18 19 /** 20 * Thrown when a PackFile previously failed and is known to be unusable 21 */ 22 public class PackInvalidException extends IOException { 23 private static final long serialVersionUID = 1L; 24 25 /** 26 * Construct a pack invalid error. 27 * 28 * @param path 29 * path of the invalid pack file. 30 * @deprecated Use {@link #PackInvalidException(File, Throwable)}. 31 */ 32 @Deprecated 33 public PackInvalidException(File path) { 34 this(path, null); 35 } 36 37 /** 38 * Construct a pack invalid error with cause. 39 * 40 * @param path 41 * path of the invalid pack file. 42 * @param cause 43 * cause of the pack file becoming invalid. 44 * @since 4.5.7 45 */ 46 public PackInvalidException(File path, Throwable cause) { 47 this(path.getAbsolutePath(), cause); 48 } 49 50 /** 51 * Construct a pack invalid error. 52 * 53 * @param path 54 * path of the invalid pack file. 55 * @deprecated Use {@link #PackInvalidException(String, Throwable)}. 56 */ 57 @Deprecated 58 public PackInvalidException(String path) { 59 this(path, null); 60 } 61 62 /** 63 * Construct a pack invalid error with cause. 64 * 65 * @param path 66 * path of the invalid pack file. 67 * @param cause 68 * cause of the pack file becoming invalid. 69 * @since 4.5.7 70 */ 71 public PackInvalidException(String path, Throwable cause) { 72 super(MessageFormat.format(JGitText.get().packFileInvalid, path), cause); 73 } 74 }