• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 
17 package android.net.ipsec.ike.exceptions;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SuppressLint;
21 import android.net.ipsec.ike.ChildSessionCallback;
22 import android.net.ipsec.ike.IkeSessionCallback;
23 
24 import java.io.IOException;
25 import java.net.UnknownHostException;
26 import java.util.Objects;
27 
28 /** Wrapper for I/O exceptions encountered during IKE operations. */
29 // Does not make sense to name it IkeIoException since "I" and "O" represent two words. The current
30 // name follows the convention set by Java.
31 @SuppressLint("AcronymName")
32 public final class IkeIOException extends IkeNonProtocolException {
33     /**
34      * Constructs a new exception with the specified cause.
35      *
36      * <p>Callers are not generally expected to instantiate this object themselves, except for
37      * testing. A reference is passed via {@link IkeSessionCallback} or {@link
38      * ChildSessionCallback}.
39      *
40      * @param cause the cause (which is saved for later retrieval by the {@link #getCause()}
41      *     method).
42      */
IkeIOException(@onNull IOException cause)43     public IkeIOException(@NonNull IOException cause) {
44         super(Objects.requireNonNull(cause, "cause MUST NOT be null"));
45     }
46 
47     /**
48      * Returns the cause of this IkeIOException.
49      *
50      * @return the cause of this IkeIOException. It might be a subclass of IOException that
51      *     represents a specific type of I/O issue. For example, {@link UnknownHostException} and
52      *     {@link IkeTimeoutException}.
53      */
54     @Override
55     @NonNull
getCause()56     public IOException getCause() {
57         return (IOException) super.getCause();
58     }
59 
60     /** @hide */
61     @Override
initCause(Throwable cause)62     public synchronized Throwable initCause(Throwable cause) {
63         throw new UnsupportedOperationException("It is not allowed to set cause with this method");
64     }
65 }
66