View Javadoc

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   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.backup.impl;
20  
21  import org.apache.hadoop.hbase.HBaseIOException;
22  import org.apache.hadoop.hbase.backup.BackupInfo;
23  import org.apache.hadoop.hbase.classification.InterfaceAudience;
24  import org.apache.hadoop.hbase.classification.InterfaceStability;
25  
26  /**
27   * Backup exception
28   */
29  @SuppressWarnings("serial")
30  @InterfaceAudience.Private
31  @InterfaceStability.Evolving
32  public class BackupException extends HBaseIOException {
33    private BackupInfo description;
34  
35    /**
36     * Some exception happened for a backup and don't even know the backup that it was about
37     * @param msg Full description of the failure
38     */
39    public BackupException(String msg) {
40      super(msg);
41    }
42  
43    /**
44     * Some exception happened for a backup with a cause
45     * @param cause the cause
46     */
47    public BackupException(Throwable cause) {
48      super(cause);
49    }
50  
51    /**
52     * Exception for the given backup that has no previous root cause
53     * @param msg reason why the backup failed
54     * @param desc description of the backup that is being failed
55     */
56    public BackupException(String msg, BackupInfo desc) {
57      super(msg);
58      this.description = desc;
59    }
60  
61    /**
62     * Exception for the given backup due to another exception
63     * @param msg reason why the backup failed
64     * @param cause root cause of the failure
65     * @param desc description of the backup that is being failed
66     */
67    public BackupException(String msg, Throwable cause, BackupInfo desc) {
68      super(msg, cause);
69      this.description = desc;
70    }
71  
72    /**
73     * Exception when the description of the backup cannot be determined, due to some other root
74     * cause
75     * @param message description of what caused the failure
76     * @param e root cause
77     */
78    public BackupException(String message, Exception e) {
79      super(message, e);
80    }
81  
82    public BackupInfo getBackupContext() {
83      return this.description;
84    }
85  
86  }