AppFunctionException


public final class AppFunctionException
extends Exception implements Parcelable

java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ android.app.appfunctions.AppFunctionException


Represents an app function related errors.

Summary

Constants

int ERROR_APP_UNKNOWN_ERROR

An unknown error occurred while processing the call in the AppFunctionService.

int ERROR_CANCELLED

The operation was cancelled.

int ERROR_CATEGORY_APP

The error is caused by the app providing the function.

int ERROR_CATEGORY_REQUEST_ERROR

The error is caused by the app requesting a function execution.

int ERROR_CATEGORY_SYSTEM

The error is caused by an issue in the system.

int ERROR_CATEGORY_UNKNOWN

The error category is unknown.

int ERROR_DENIED

The caller does not have the permission to execute an app function.

int ERROR_DISABLED

The caller tried to execute a disabled app function.

int ERROR_FUNCTION_NOT_FOUND

The caller tried to execute a function that does not exist.

int ERROR_INVALID_ARGUMENT

The caller supplied invalid arguments to the execution request.

int ERROR_SYSTEM_ERROR

An internal unexpected error coming from the system.

Inherited constants

Fields

public static final Creator<AppFunctionException> CREATOR

Public constructors

AppFunctionException(int errorCode, String errorMessage)
AppFunctionException(int errorCode, String errorMessage, Bundle extras)

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getErrorCategory()

Returns the error category.

int getErrorCode()

Returns one of the ERROR constants.

String getErrorMessage()

Returns the error message.

Bundle getExtras()

Returns any extras associated with this error.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

ERROR_APP_UNKNOWN_ERROR

public static final int ERROR_APP_UNKNOWN_ERROR

An unknown error occurred while processing the call in the AppFunctionService.

This error is thrown when the service is connected in the remote application but an unexpected error is thrown from the bound application.

This error is in the ERROR_CATEGORY_APP category.

Constant Value: 3000 (0x00000bb8)

ERROR_CANCELLED

public static final int ERROR_CANCELLED

The operation was cancelled. Use this error code to report that a cancellation is done after receiving a cancellation signal.

This error is in the ERROR_CATEGORY_SYSTEM category.

Constant Value: 2001 (0x000007d1)

ERROR_CATEGORY_APP

public static final int ERROR_CATEGORY_APP

The error is caused by the app providing the function.

For example, the app crashed when the system is executing the request.

Errors in the category fall in the range 3000-3999 inclusive.

Constant Value: 3 (0x00000003)

ERROR_CATEGORY_REQUEST_ERROR

public static final int ERROR_CATEGORY_REQUEST_ERROR

The error is caused by the app requesting a function execution.

For example, the caller provided invalid parameters in the execution request e.g. an invalid function ID.

Errors in the category fall in the range 1000-1999 inclusive.

Constant Value: 1 (0x00000001)

ERROR_CATEGORY_SYSTEM

public static final int ERROR_CATEGORY_SYSTEM

The error is caused by an issue in the system.

For example, the AppFunctionService implementation is not found by the system.

Errors in the category fall in the range 2000-2999 inclusive.

Constant Value: 2 (0x00000002)

ERROR_CATEGORY_UNKNOWN

public static final int ERROR_CATEGORY_UNKNOWN

The error category is unknown.

This is the default value for getErrorCategory().

Constant Value: 0 (0x00000000)

ERROR_DENIED

public static final int ERROR_DENIED

The caller does not have the permission to execute an app function.

This error is in the ERROR_CATEGORY_REQUEST_ERROR category.

Constant Value: 1000 (0x000003e8)

ERROR_DISABLED

public static final int ERROR_DISABLED

The caller tried to execute a disabled app function.

This error is in the ERROR_CATEGORY_REQUEST_ERROR category.

Constant Value: 1002 (0x000003ea)

ERROR_FUNCTION_NOT_FOUND

public static final int ERROR_FUNCTION_NOT_FOUND

The caller tried to execute a function that does not exist.

This error is in the ERROR_CATEGORY_REQUEST_ERROR category.

Constant Value: 1003 (0x000003eb)

ERROR_INVALID_ARGUMENT

public static final int ERROR_INVALID_ARGUMENT

The caller supplied invalid arguments to the execution request.

This error may be considered similar to IllegalArgumentException.

This error is in the ERROR_CATEGORY_REQUEST_ERROR category.

Constant Value: 1001 (0x000003e9)

ERROR_SYSTEM_ERROR

public static final int ERROR_SYSTEM_ERROR

An internal unexpected error coming from the system.

This error is in the ERROR_CATEGORY_SYSTEM category.

Constant Value: 2000 (0x000007d0)

Fields

CREATOR

public static final Creator<AppFunctionException> CREATOR

Public constructors

AppFunctionException

public AppFunctionException (int errorCode, 
                String errorMessage)

Parameters
errorCode int: The error code. Value is ERROR_DENIED, ERROR_APP_UNKNOWN_ERROR, ERROR_FUNCTION_NOT_FOUND, ERROR_SYSTEM_ERROR, ERROR_INVALID_ARGUMENT, ERROR_DISABLED, or ERROR_CANCELLED

errorMessage String: The error message. This value may be null.

AppFunctionException

public AppFunctionException (int errorCode, 
                String errorMessage, 
                Bundle extras)

Parameters
errorCode int: The error code. Value is ERROR_DENIED, ERROR_APP_UNKNOWN_ERROR, ERROR_FUNCTION_NOT_FOUND, ERROR_SYSTEM_ERROR, ERROR_INVALID_ARGUMENT, ERROR_DISABLED, or ERROR_CANCELLED

errorMessage String: The error message. This value may be null.

extras Bundle: The extras associated with this error. This value cannot be null.

Public methods

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getErrorCategory

public int getErrorCategory ()

Returns the error category.

This method categorizes errors based on their underlying cause, allowing developers to implement targeted error handling and provide more informative error messages to users. It maps ranges of error codes to specific error categories.

This method returns ERROR_CATEGORY_UNKNOWN if the error code does not belong to any error category.

See ERROR(ErrorCategory/android.app.appfunctions.AppFunctionException.ErrorCategory ErrorCategory) for a complete list of error categories and their corresponding error code ranges.

Returns
int Value is ERROR_CATEGORY_UNKNOWN, ERROR_CATEGORY_REQUEST_ERROR, ERROR_CATEGORY_APP, or ERROR_CATEGORY_SYSTEM

getErrorCode

public int getErrorCode ()

Returns one of the ERROR constants.

Returns
int Value is ERROR_DENIED, ERROR_APP_UNKNOWN_ERROR, ERROR_FUNCTION_NOT_FOUND, ERROR_SYSTEM_ERROR, ERROR_INVALID_ARGUMENT, ERROR_DISABLED, or ERROR_CANCELLED

getErrorMessage

public String getErrorMessage ()

Returns the error message.

Returns
String This value may be null.

getExtras

public Bundle getExtras ()

Returns any extras associated with this error.

Returns
Bundle This value cannot be null.

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES