Error Handling
The SDK uses a structured error system for reliable error handling:
import { SDKError, isSDKError } from '@funtico/gameloop-sdk';
try { const userInfo = await sdk.getUserInfo();} catch (error) { if (isSDKError(error)) { console.error('SDK Error:', error.name, error.status);
switch (error.name) { case 'auth_error': // User needs to re-authenticate console.log('Please log in again'); await sdk.signInWithFuntico(window.location.href); break;
case 'internal_server_error': // Server or network issues console.error('Service temporarily unavailable'); break; } } else { console.error('Unexpected error:', error); }}Error Types
Section titled “Error Types”| Error Type | Status Codes | Description | Recommended Action |
|---|---|---|---|
auth_error | 401, 403 | Authentication required or expired | Redirect to login |
internal_server_error | 400, 500+ | Server or request errors | Show error message, retry |
Error Class
Section titled “Error Class”class SDKError { name: 'auth_error' | 'internal_server_error'; status: number;}
// Type guard functionfunction isSDKError(error: unknown): error is SDKError