TooLargeObjectInPackException.java

  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. package org.eclipse.jgit.errors;

  11. import java.text.MessageFormat;

  12. import org.eclipse.jgit.internal.JGitText;
  13. import org.eclipse.jgit.transport.URIish;

  14. /**
  15.  * Thrown when PackParser finds an object larger than a predefined limit
  16.  */
  17. public class TooLargeObjectInPackException extends TransportException {
  18.     private static final long serialVersionUID = 1L;

  19.     /**
  20.      * Construct a too large object in pack exception when the exact size of the
  21.      * too large object is not available. This will be used when we find out
  22.      * that a delta sequence is already larger than the maxObjectSizeLimit but
  23.      * don't want to inflate the delta just to find out the exact size of the
  24.      * resulting object.
  25.      *
  26.      * @param maxObjectSizeLimit
  27.      *            the maximum object size limit
  28.      */
  29.     public TooLargeObjectInPackException(long maxObjectSizeLimit) {
  30.         super(MessageFormat.format(JGitText.get().receivePackObjectTooLarge1,
  31.                 Long.valueOf(maxObjectSizeLimit)));
  32.     }

  33.     /**
  34.      * Construct a too large object in pack exception when the exact size of the
  35.      * too large object is known.
  36.      *
  37.      * @param objectSize
  38.      *            a long.
  39.      * @param maxObjectSizeLimit
  40.      *            a long.
  41.      */
  42.     public TooLargeObjectInPackException(long objectSize,
  43.             long maxObjectSizeLimit) {
  44.         super(MessageFormat.format(JGitText.get().receivePackObjectTooLarge2,
  45.                 Long.valueOf(objectSize), Long.valueOf(maxObjectSizeLimit)));
  46.     }

  47.     /**
  48.      * Construct a too large object in pack exception.
  49.      *
  50.      * @param uri
  51.      *            URI used for transport
  52.      * @param s
  53.      *            message
  54.      * @since 4.4
  55.      */
  56.     public TooLargeObjectInPackException(URIish uri, String s) {
  57.         super(uri.setPass(null) + ": " + s); //$NON-NLS-1$
  58.     }
  59. }