ArchiveException.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one
  3.  * or more contributor license agreements.  See the NOTICE file
  4.  * distributed with this work for additional information
  5.  * regarding copyright ownership.  The ASF licenses this file
  6.  * to you under the Apache License, Version 2.0 (the
  7.  * "License"); you may not use this file except in compliance
  8.  * with the License.  You may obtain a copy of the License at
  9.  *
  10.  *   https://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing,
  13.  * software distributed under the License is distributed on an
  14.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15.  * KIND, either express or implied.  See the License for the
  16.  * specific language governing permissions and limitations
  17.  * under the License.
  18.  */
  19. package org.apache.commons.compress.archivers;

  20. import java.util.function.Supplier;

  21. import org.apache.commons.compress.CompressException;

  22. /**
  23.  * Signals that an Archive exception of some sort has occurred.
  24.  */
  25. public class ArchiveException extends CompressException {

  26.     /** Serial. */
  27.     private static final long serialVersionUID = 2772690708123267100L;

  28.     /**
  29.      * Checks that the specified object reference is not {@code null} and throws a customized {@link ArchiveException} if it is. *
  30.      *
  31.      * @param obj             the object reference to check for nullity.
  32.      * @param messageSupplier supplier of the detail message to be used in the event that a {@code ArchiveException} is thrown
  33.      * @param <T>             the type of the reference.
  34.      * @return {@code obj} if not {@code null}
  35.      * @throws ArchiveException if {@code obj} is {@code null}
  36.      * @since 1.28.0
  37.      */
  38.     public static <T> T requireNonNull(final T obj, final Supplier<String> messageSupplier) throws ArchiveException {
  39.         return CompressException.requireNonNull(ArchiveException.class, obj, messageSupplier);
  40.     }

  41.     /**
  42.      * Constructs an {@code ArchiveException} with {@code null} as its error detail message.
  43.      *
  44.      * @since 1.28.0
  45.      */
  46.     public ArchiveException() {
  47.         // empty
  48.     }

  49.     /**
  50.      * Constructs a new exception with the specified detail message. The cause is not initialized.
  51.      *
  52.      * @param message The message (which is saved for later retrieval by the {@link #getMessage()} method).
  53.      */
  54.     public ArchiveException(final String message) {
  55.         super(message);
  56.     }

  57.     /**
  58.      * Constructs a new exception with the specified detail message and cause.
  59.      *
  60.      * @param message The message (which is saved for later retrieval by the {@link #getMessage()} method).
  61.      * @param cause   The cause (which is saved for later retrieval by the {@link #getCause()} method). A null value indicates that the cause is nonexistent or
  62.      *                unknown.
  63.      * @deprecated Use {@link #ArchiveException(String, Throwable)}.
  64.      */
  65.     @Deprecated
  66.     public ArchiveException(final String message, final Exception cause) {
  67.         super(message, cause);
  68.     }

  69.     /**
  70.      * Constructs a new exception with the specified detail message and cause.
  71.      *
  72.      * @param message The message (which is saved for later retrieval by the {@link #getMessage()} method).
  73.      * @param cause   The cause (which is saved for later retrieval by the {@link #getCause()} method). A null value indicates that the cause is nonexistent or
  74.      *                unknown.
  75.      * @since 1.28.0
  76.      */
  77.     public ArchiveException(final String message, final Throwable cause) {
  78.         super(message, cause);
  79.     }

  80.     /**
  81.      * Constructs a {@code ArchiveException} with the specified cause and a detail message.
  82.      *
  83.      * @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is permitted, and indicates that the cause
  84.      *              is nonexistent or unknown.)
  85.      * @since 1.28.0
  86.      */
  87.     public ArchiveException(final Throwable cause) {
  88.         super(cause);
  89.     }
  90. }