[Thread] add error code ERROR_UNKNOWN for forward compatibility
This is per the go/android-api-guidelines#return-error: ``` Make sure your chosen error handling option gives you the flexibility to introduce new error types in the future. For @IntDef, that means including an OTHER or UNKNOWN value - when returning a new code, you can check the caller's targetSdkVersion to avoid returning an error code the application doesn't know about. For exceptions, have a common superclass that your exceptions implement, so that any code that handles that type will also catch and handle subtypes. ``` Bug: 320403080 Change-Id: I2ee663b75107dac6d84fa697f449fa0424128fde
This commit is contained in:
parent
ad93a191e7
commit
2c83e2fcc9
2 changed files with 8 additions and 0 deletions
|
|
@ -532,6 +532,7 @@ package android.net.thread {
|
|||
field public static final int ERROR_RESPONSE_BAD_FORMAT = 9; // 0x9
|
||||
field public static final int ERROR_TIMEOUT = 3; // 0x3
|
||||
field public static final int ERROR_UNAVAILABLE = 4; // 0x4
|
||||
field public static final int ERROR_UNKNOWN = 11; // 0xb
|
||||
field public static final int ERROR_UNSUPPORTED_CHANNEL = 7; // 0x7
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class ThreadNetworkException extends Exception {
|
|||
ERROR_REJECTED_BY_PEER,
|
||||
ERROR_RESPONSE_BAD_FORMAT,
|
||||
ERROR_RESOURCE_EXHAUSTED,
|
||||
ERROR_UNKNOWN,
|
||||
})
|
||||
public @interface ErrorCode {}
|
||||
|
||||
|
|
@ -122,6 +123,12 @@ public class ThreadNetworkException extends Exception {
|
|||
*/
|
||||
public static final int ERROR_RESOURCE_EXHAUSTED = 10;
|
||||
|
||||
/**
|
||||
* The operation failed because of an unknown error in the system. This typically indicates
|
||||
* that the caller doesn't understand error codes added in newer Android versions.
|
||||
*/
|
||||
public static final int ERROR_UNKNOWN = 11;
|
||||
|
||||
private final int mErrorCode;
|
||||
|
||||
/** Creates a new {@link ThreadNetworkException} object with given error code and message. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue