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 error.

This exception may include an Bundle containing additional error-specific metadata.

The AppFunction SDK can expose structured APIs by packing and unpacking this Bundle.

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_ENTERPRISE_POLICY_DISALLOWED

The operation was disallowed by enterprise policy.

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

int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)".

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

final void addSuppressed(Throwable exception)

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.

Throwable fillInStackTrace()

Fills in the execution stack trace.

Throwable getCause()

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

String getLocalizedMessage()

Creates a localized description of this throwable.

String getMessage()

Returns the detail message string of this throwable.

StackTraceElement[] getStackTrace()

Provides programmatic access to the stack trace information printed by printStackTrace().

final Throwable[] getSuppressed()

Returns an array containing all of the exceptions that were suppressed, typically by the try-with-resources statement, in order to deliver this exception.

Throwable initCause(Throwable cause)

Initializes the cause of this throwable to the specified value.

void printStackTrace()

Prints this throwable and its backtrace to the standard error stream.

void printStackTrace(PrintWriter s)

Prints this throwable and its backtrace to the specified print writer.

void printStackTrace(PrintStream s)

Prints this throwable and its backtrace to the specified print stream.

void setStackTrace(StackTraceElement[] stackTrace)

Sets the stack trace elements that will be returned by getStackTrace() and printed by printStackTrace() and related methods.

String toString()

Returns a short description of this throwable.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

abstract int describeContents()

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

abstract void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

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_ENTERPRISE_POLICY_DISALLOWED

public static final int ERROR_ENTERPRISE_POLICY_DISALLOWED

The operation was disallowed by enterprise policy.

This error is in the ERROR_CATEGORY_SYSTEM category.

Constant Value: 2002 (0x000007d2)

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, ERROR_CANCELLED, or ERROR_ENTERPRISE_POLICY_DISALLOWED

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, ERROR_CANCELLED, or ERROR_ENTERPRISE_POLICY_DISALLOWED

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.

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