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.yetus.audience.InterfaceAudience;
022import org.apache.hadoop.hbase.client.SnapshotDescription;
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
031  private SnapshotDescription description;
032
033  /**
034   * Some exception happened for a snapshot and don't even know the snapshot that it was about
035   * @param msg Full description of the failure
036   */
037  public HBaseSnapshotException(String msg) {
038    super(msg);
039  }
040
041  /**
042   * Exception for the given snapshot that has no previous root cause
043   * @param msg reason why the snapshot failed
044   * @param desc description of the snapshot that is being failed
045   */
046  public HBaseSnapshotException(String msg, SnapshotDescription desc) {
047    super(msg);
048    this.description = desc;
049  }
050
051  /**
052   * Exception for the given snapshot due to another exception
053   * @param msg reason why the snapshot failed
054   * @param cause root cause of the failure
055   * @param desc description of the snapshot that is being failed
056   */
057  public HBaseSnapshotException(String msg, Throwable cause, SnapshotDescription desc) {
058    super(msg, cause);
059    this.description = desc;
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 e root cause
067   */
068  public HBaseSnapshotException(String message, Exception e) {
069    super(message, e);
070  }
071
072  public SnapshotDescription getSnapshotDescription() {
073    return this.description;
074  }
075}