1 /* 2 * Copyright (C) 2009, Google Inc. 3 * Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk> 4 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com> 5 * Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others 6 * 7 * This program and the accompanying materials are made available under the 8 * terms of the Eclipse Distribution License v. 1.0 which is available at 9 * https://www.eclipse.org/org/documents/edl-v10.php. 10 * 11 * SPDX-License-Identifier: BSD-3-Clause 12 */ 13 14 package org.eclipse.jgit.errors; 15 16 import java.io.IOException; 17 import java.text.MessageFormat; 18 19 import org.eclipse.jgit.internal.JGitText; 20 import org.eclipse.jgit.lib.Constants; 21 import org.eclipse.jgit.lib.ObjectId; 22 23 /** 24 * An inconsistency with respect to handling different object types. 25 * 26 * This most likely signals a programming error rather than a corrupt 27 * object database. 28 */ 29 public class IncorrectObjectTypeException extends IOException { 30 private static final long serialVersionUID = 1L; 31 32 /** 33 * Construct an IncorrectObjectTypeException for the specified object id. 34 * 35 * Provide the type to make it easier to track down the problem. 36 * 37 * @param id SHA-1 38 * @param type object type 39 */ 40 public IncorrectObjectTypeException(ObjectId id, String type) { 41 super(MessageFormat.format(JGitText.get().objectIsNotA, id.name(), type)); 42 } 43 44 /** 45 * Construct an IncorrectObjectTypeException for the specified object id. 46 * 47 * Provide the type to make it easier to track down the problem. 48 * 49 * @param id SHA-1 50 * @param type object type 51 */ 52 public IncorrectObjectTypeException(ObjectId id, int type) { 53 this(id, Constants.typeString(type)); 54 } 55 }