1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.net.ipsec.ike.exceptions;
17 
18 import com.android.internal.net.ipsec.ike.shim.ShimUtils;
19 
20 /**
21  * IkeException represents a generic exception that includes internal and protocol exceptions.
22  */
23 public abstract class IkeException extends Exception {
24     /** @hide */
IkeException()25     protected IkeException() {
26         super();
27     }
28 
29     /** @hide */
IkeException(String message)30     protected IkeException(String message) {
31         super(message);
32     }
33 
34     /** @hide */
IkeException(Throwable cause)35     protected IkeException(Throwable cause) {
36         super(cause);
37     }
38 
39     /** @hide */
IkeException(String message, Throwable cause)40     protected IkeException(String message, Throwable cause) {
41         super(message, cause);
42     }
43 
44     /**
45      * Wrap Exception as an IkeException or do nothing if the input is already an IkeException.
46      *
47      * @hide
48      */
wrapAsIkeException(Exception exception)49     public static IkeException wrapAsIkeException(Exception exception) {
50         return ShimUtils.getInstance().getWrappedIkeException(exception);
51     }
52 
53     /**
54      * Returns the error code for metrics
55      *
56      * @hide
57      */
getMetricsErrorCode()58     public abstract int getMetricsErrorCode();
59 }
60