Type guard to check if an error is an SDK error
This function checks if an error object has the structure of an SDK error by verifying it has the required properties: message, code, and status.
Any error object to check
True if the error is an SDK error, false otherwise
try { const users = await mosaia.users.get();} catch (error) { if (isSdkError(error)) { console.log('SDK Error:', error.message); console.log('Error Code:', error.code); console.log('Status:', error.status); } else { console.log('Unexpected error:', error); }} Copy
try { const users = await mosaia.users.get();} catch (error) { if (isSdkError(error)) { console.log('SDK Error:', error.message); console.log('Error Code:', error.code); console.log('Status:', error.status); } else { console.log('Unexpected error:', error); }}
Type guard to check if an error is an SDK error
This function checks if an error object has the structure of an SDK error by verifying it has the required properties: message, code, and status.