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.backup.impl;
019
020import org.apache.hadoop.hbase.HBaseIOException;
021import org.apache.hadoop.hbase.backup.BackupInfo;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Backup exception
026 */
027@SuppressWarnings("serial")
028@InterfaceAudience.Private
029public class BackupException extends HBaseIOException {
030  private BackupInfo info;
031
032  /**
033   * Some exception happened for a backup and don't even know the backup that it was about
034   * @param msg Full description of the failure
035   */
036  public BackupException(String msg) {
037    super(msg);
038  }
039
040  /**
041   * Some exception happened for a backup with a cause
042   * @param cause the cause
043   */
044  public BackupException(Throwable cause) {
045    super(cause);
046  }
047
048  /**
049   * Exception for the given backup that has no previous root cause
050   * @param msg  reason why the backup failed
051   * @param desc description of the backup that is being failed
052   */
053  public BackupException(String msg, BackupInfo desc) {
054    super(msg);
055    this.info = desc;
056  }
057
058  /**
059   * Exception for the given backup due to another exception
060   * @param msg   reason why the backup failed
061   * @param cause root cause of the failure
062   * @param desc  description of the backup that is being failed
063   */
064  public BackupException(String msg, Throwable cause, BackupInfo desc) {
065    super(msg, cause);
066    this.info = desc;
067  }
068
069  /**
070   * Exception when the description of the backup cannot be determined, due to some other root cause
071   * @param message description of what caused the failure
072   * @param e       root cause
073   */
074  public BackupException(String message, Exception e) {
075    super(message, e);
076  }
077
078  public BackupInfo getBackupInfo() {
079    return this.info;
080  }
081
082}