1 /* 2 * Copyright (C) 2017, 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 org.eclipse.jgit.annotations.Nullable; 14 15 /** 16 * Exception thrown when encounters a corrupt pack index file. 17 * 18 * @since 4.9 19 */ 20 public class CorruptPackIndexException extends Exception { 21 private static final long serialVersionUID = 1L; 22 23 /** The error type of a corrupt index file. */ 24 public enum ErrorType { 25 /** Offset does not match index in pack file. */ 26 MISMATCH_OFFSET, 27 /** CRC does not match CRC of the object data in pack file. */ 28 MISMATCH_CRC, 29 /** CRC is not present in index file. */ 30 MISSING_CRC, 31 /** Object in pack is not present in index file. */ 32 MISSING_OBJ, 33 /** Object in index file is not present in pack file. */ 34 UNKNOWN_OBJ, 35 } 36 37 private ErrorType errorType; 38 39 /** 40 * Report a specific error condition discovered in an index file. 41 * 42 * @param message 43 * the error message. 44 * @param errorType 45 * the error type of corruption. 46 */ 47 public CorruptPackIndexException(String message, ErrorType errorType) { 48 super(message); 49 this.errorType = errorType; 50 } 51 52 /** 53 * Specific the reason of the corrupt index file. 54 * 55 * @return error condition or null. 56 */ 57 @Nullable 58 public ErrorType getErrorType() { 59 return errorType; 60 } 61 }