1 /* 2 * Copyright (C) 2016, 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.transport; 12 13 import java.text.MessageFormat; 14 15 import org.eclipse.jgit.errors.PackProtocolException; 16 import org.eclipse.jgit.internal.JGitText; 17 import org.eclipse.jgit.lib.AnyObjectId; 18 19 /** 20 * Indicates client requested an object the server does not want to serve. 21 * <p> 22 * Typically visible only inside of the server implementation; clients are 23 * usually looking at the text message from the server in a generic 24 * {@link org.eclipse.jgit.errors.PackProtocolException}. 25 * 26 * @since 4.3 27 */ 28 public class WantNotValidException extends PackProtocolException { 29 private static final long serialVersionUID = 1L; 30 31 /** 32 * Construct a {@code "want $id not valid"} exception. 33 * 34 * @param id 35 * invalid object identifier received from the client. 36 */ 37 public WantNotValidException(AnyObjectId id) { 38 super(msg(id)); 39 } 40 41 /** 42 * Construct a {@code "want $id not valid"} exception. 43 * 44 * @param id 45 * invalid object identifier received from the client. 46 * @param cause 47 * root cause of the object being invalid, such as an IOException 48 * from the storage system. 49 */ 50 public WantNotValidException(AnyObjectId id, Throwable cause) { 51 super(msg(id), cause); 52 } 53 54 private static String msg(AnyObjectId id) { 55 return MessageFormat.format(JGitText.get().wantNotValid, id.name()); 56 } 57 }