View Javadoc
1   /*
2    * Copyright (C) 2011, Sasa Zivkov <sasa.zivkov@sap.com> 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.text.MessageFormat;
14  
15  import org.eclipse.jgit.internal.JGitText;
16  import org.eclipse.jgit.transport.URIish;
17  
18  /**
19   * Thrown when PackParser finds an object larger than a predefined limit
20   */
21  public class TooLargeObjectInPackException extends TransportException {
22  	private static final long serialVersionUID = 1L;
23  
24  	/**
25  	 * Construct a too large object in pack exception when the exact size of the
26  	 * too large object is not available. This will be used when we find out
27  	 * that a delta sequence is already larger than the maxObjectSizeLimit but
28  	 * don't want to inflate the delta just to find out the exact size of the
29  	 * resulting object.
30  	 *
31  	 * @param maxObjectSizeLimit
32  	 *            the maximum object size limit
33  	 */
34  	public TooLargeObjectInPackException(long maxObjectSizeLimit) {
35  		super(MessageFormat.format(JGitText.get().receivePackObjectTooLarge1,
36  				Long.valueOf(maxObjectSizeLimit)));
37  	}
38  
39  	/**
40  	 * Construct a too large object in pack exception when the exact size of the
41  	 * too large object is known.
42  	 *
43  	 * @param objectSize
44  	 *            a long.
45  	 * @param maxObjectSizeLimit
46  	 *            a long.
47  	 */
48  	public TooLargeObjectInPackException(long objectSize,
49  			long maxObjectSizeLimit) {
50  		super(MessageFormat.format(JGitText.get().receivePackObjectTooLarge2,
51  				Long.valueOf(objectSize), Long.valueOf(maxObjectSizeLimit)));
52  	}
53  
54  	/**
55  	 * Construct a too large object in pack exception.
56  	 *
57  	 * @param uri
58  	 *            URI used for transport
59  	 * @param s
60  	 *            message
61  	 * @since 4.4
62  	 */
63  	public TooLargeObjectInPackException(URIish uri, String s) {
64  		super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
65  	}
66  }