Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 865fdc75 authored by Robert Quattlebaum's avatar Robert Quattlebaum
Browse files

LowpanException: Refactor exception handling

Got rid of the exposed exception code and we now rely on subclasses of
LowpanException. Also introduces a new exception: LowpanRuntimeException

LowpanRuntimeException, as a subclass of AndroidRuntimeException,
doesn't need explicitly delared "throws" statements for function
declarations. Most Exceptions are still LowpanExceptions, but some
specific error codes, such as ERROR_NCP_PROBLEM, are now using this
new exception class.

Bug: b/63708181
Change-Id: Idba6233ac4803d33561b5aa951c8fa846c3ab1d8
parent 93ea3ce9
Loading
Loading
Loading
Loading
+11 −16
Original line number Diff line number Diff line
@@ -137,22 +137,17 @@ interface ILowpanInterface {
    const int ERROR_INVALID_ARGUMENT = 2;
    const int ERROR_DISABLED = 3;
    const int ERROR_WRONG_STATE = 4;
    const int ERROR_INVALID_TYPE = 5;
    const int ERROR_INVALID_VALUE = 6;
    const int ERROR_TIMEOUT = 7;
    const int ERROR_IO_FAILURE = 8;
    const int ERROR_BUSY = 9;
    const int ERROR_ALREADY = 10;
    const int ERROR_CANCELED = 11;
    const int ERROR_CREDENTIAL_NEEDED = 12;
    const int ERROR_FEATURE_NOT_SUPPORTED = 14;
    const int ERROR_PROPERTY_NOT_FOUND = 16;
    const int ERROR_JOIN_FAILED_UNKNOWN = 18;
    const int ERROR_JOIN_FAILED_AT_SCAN = 19;
    const int ERROR_JOIN_FAILED_AT_AUTH = 20;
    const int ERROR_FORM_FAILED_AT_SCAN = 21;
    const int ERROR_NCP_PROBLEM = 27;
    const int ERROR_PERMISSION_DENIED = 28;
    const int ERROR_TIMEOUT = 5;
    const int ERROR_IO_FAILURE = 6;
    const int ERROR_NCP_PROBLEM = 7;
    const int ERROR_BUSY = 8;
    const int ERROR_ALREADY = 9;
    const int ERROR_CANCELED = 10;
    const int ERROR_FEATURE_NOT_SUPPORTED = 11;
    const int ERROR_JOIN_FAILED_UNKNOWN = 12;
    const int ERROR_JOIN_FAILED_AT_SCAN = 13;
    const int ERROR_JOIN_FAILED_AT_AUTH = 14;
    const int ERROR_FORM_FAILED_AT_SCAN = 15;

    //////////////////////////////////////////////////////////////////////////
    // Methods
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.lowpan;

/**
 * Exception indicating this operation requires the interface to be enabled.
 *
 * @see LowpanInterface
 * @hide
 */
// @SystemApi
public class InterfaceDisabledException extends LowpanException {

    public InterfaceDisabledException() {}

    public InterfaceDisabledException(String message) {
        super(message);
    }

    public InterfaceDisabledException(String message, Throwable cause) {
        super(message, cause);
    }

    protected InterfaceDisabledException(Exception cause) {
        super(cause);
    }
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.lowpan;

/**
 * Exception indicating the join operation was unable to find the given network.
 *
 * @see LowpanInterface
 * @hide
 */
// @SystemApi
public class JoinFailedAtAuthException extends JoinFailedException {

    public JoinFailedAtAuthException() {}

    public JoinFailedAtAuthException(String message) {
        super(message);
    }

    public JoinFailedAtAuthException(String message, Throwable cause) {
        super(message, cause);
    }

    public JoinFailedAtAuthException(Exception cause) {
        super(cause);
    }
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.lowpan;

/**
 * Exception indicating the join operation was unable to find the given network.
 *
 * @see LowpanInterface
 * @hide
 */
// @SystemApi
public class JoinFailedAtScanException extends JoinFailedException {

    public JoinFailedAtScanException() {}

    public JoinFailedAtScanException(String message) {
        super(message);
    }

    public JoinFailedAtScanException(String message, Throwable cause) {
        super(message, cause);
    }

    public JoinFailedAtScanException(Exception cause) {
        super(cause);
    }
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.lowpan;

/**
 * Exception indicating the join operation has failed.
 *
 * @see LowpanInterface
 * @hide
 */
// @SystemApi
public class JoinFailedException extends LowpanException {

    public JoinFailedException() {}

    public JoinFailedException(String message) {
        super(message);
    }

    public JoinFailedException(String message, Throwable cause) {
        super(message, cause);
    }

    protected JoinFailedException(Exception cause) {
        super(cause);
    }
}
Loading