001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.snapshot;
019
020import org.apache.hadoop.hbase.DoNotRetryIOException;
021import org.apache.hadoop.hbase.client.SnapshotDescription;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * General exception base class for when a snapshot fails.
026 */
027@SuppressWarnings("serial")
028@InterfaceAudience.Public
029public class HBaseSnapshotException extends DoNotRetryIOException {
030  private SnapshotDescription description;
031
032  /**
033   * Some exception happened for a snapshot and don't even know the snapshot that it was about.
034   * @param message the full description of the failure
035   */
036  public HBaseSnapshotException(String message) {
037    super(message);
038  }
039
040  /**
041   * Exception for the given snapshot that has no previous root cause.
042   * @param message             the reason why the snapshot failed
043   * @param snapshotDescription the description of the snapshot that is failing
044   */
045  public HBaseSnapshotException(String message, SnapshotDescription snapshotDescription) {
046    super(message);
047    this.description = snapshotDescription;
048  }
049
050  /**
051   * Exception for the given snapshot due to another exception.
052   * @param message             the reason why the snapshot failed
053   * @param cause               the root cause of the failure
054   * @param snapshotDescription the description of the snapshot that is being failed
055   */
056  public HBaseSnapshotException(String message, Throwable cause,
057    SnapshotDescription snapshotDescription) {
058    super(message, cause);
059    this.description = snapshotDescription;
060  }
061
062  /**
063   * Exception when the description of the snapshot cannot be determined, due to some root other
064   * root cause.
065   * @param message description of what caused the failure
066   * @param cause   the root cause
067   */
068  public HBaseSnapshotException(String message, Throwable cause) {
069    super(message, cause);
070  }
071
072  /** Returns the description of the snapshot that is being failed */
073  public SnapshotDescription getSnapshotDescription() {
074    return this.description;
075  }
076}