Server Error Handling

When the request fails on the server, it can return a known error for you to interpret to the user and use to log it for better error reporting.

Server errors are returned in response.responseError. Requests can also throw errors, including WPNException from PowerAuth Networking JS and WMTException for Mobile Token validation. Handle these in catch.

Example error handling

In React Native, import WPNKnownRestApiError from react-native-powerauth-networking. In Cordova, it is available as a global provided by the cordova-powerauth-networking plugin.

import { WPNKnownRestApiError } from "react-native-powerauth-networking" // React Native only

// Approve operation with a password
async function approve(operation: WMTOnlineOperation, password: string) {
    try {
        const auth = PowerAuthAuthentication.password(password)
        const response = await this.operations.authorize(operation, auth)
        if (response.status == "OK") {
            // operation authorized
        } else {
            if (response.responseError?.code == WPNKnownRestApiError.OperationAlreadyFinished) {
                // the operation was already approved)
            } else {
                // other handling
            }
        }
    } catch (e) {
        // failure (for example network not available or invalid powerauth state)
    }
}

Known API Error codes

When the API call response has responseError, the code property can contain the following errors:

Error Code Description
ERROR_GENERIC When unexpected error happened
POWERAUTH_AUTH_FAIL General authentication failure (wrong password, wrong activation state, etc…)
INVALID_REQUEST Invalid request sent - missing request object in the request
INVALID_ACTIVATION Activation is not valid (it is different from configured activation)
PUSH_REGISTRATION_FAILED Error code for a situation when registration to push notification fails
OPERATION_ALREADY_FINISHED Operation is already finished
OPERATION_ALREADY_FAILED Operation is already failed
OPERATION_ALREADY_CANCELED Operation is canceled
OPERATION_EXPIRED Operation is expired
OPERATION_FAILED Default operation action failure
ERR_AUTHENTICATION Error in case that PowerAuth authentication fails
ERR_SECURE_VAULT Error during secure vault unlocking
ERR_ENCRYPTION Returned in case encryption or decryption fails
Last updated on Oct 09, 2026 (11:13) Edit on Github Send Feedback

3.0.x

Mobile Token SDK JS