The WebView library implements a comprehensive error handling system that operates across both JavaScript and native SDKs. Errors are communicated bi-directionally through a promise-based architecture, ensuring reliable error reporting and recovery.
All asynchronous methods return a Promise whose "resolve" and "reject" callbacks are stored and executed when a result is returned successfully, or an error is thrown from the native SDK, respectively.

The library also performs synchronous parameter validation before invoking native code, throwing errors immediately for invalid inputs. Below is an example.
try {
const user = window.insider.getCurrentUser();
await user.setAge(25.5); // Invalid: must be integer
} catch (error) {
console.error(error.message);
// Output: [setAge] Parameter "age" expected to be of type "integer", but got value: 25.5
}Parameter validation rules
The library validates all parameters before sending them to native SDKs based on the following validation rules.
Type | Validation rules |
|---|---|
String | Must be a non-empty string |
Integer | Must be a number, and Number.isInteger() returns true |
Double | Must be a number and Number.isFinite() returns true |
Boolean | Must be true or false |
Date | Must be an instance of Date |
Array | Must be a non-empty array with elements matching the specified type |
Below is an example.
// Gender must be one of the allowed values
await user.setGender('male'); // ✓ Valid
await user.setGender('female'); // ✓ Valid
await user.setGender('other'); // ✓ Valid
await user.setGender('unknown'); // ✗ Error: not in allowed values