Important: When errors thrown by callback functions are not handled by the parent application, Proview will swallow these errors to prevent disruption of the SDK’s core functionality. Always implement proper error handling within your callback functions.
When implementing callback functions for session hooks or API methods, always include proper error handling:
Copy
Ask AI
// Good - Handle errors in callbacksProview.session.onSessionPause("User requested break", function (sessionStateOutput, err) { try { if (err) { console.error('Hook error:', err); return; } console.log('Session paused. Reason:', sessionStateOutput.reason); console.log('Session state:', sessionStateOutput.state); // Your custom logic here saveUserProgress(); showPauseUI(); } catch (error) { console.error('Error in pause handler:', error); // Handle the error appropriately }});// Bad - Unhandled errorsProview.session.onSessionPause("User requested break", function (sessionStateOutput, err) { // If this throws an error, Proview will swallow it riskyOperation(); // Could throw an error});