When using the Bags TypeScript SDK, errors are automatically handled and thrown as exceptions. The SDK wraps API responses and throws errors for failed requests:
import { BagsSDK } from "@bagsfm/bags-sdk";try { const sdk = new BagsSDK(apiKey, connection); const result = await sdk.tokenLaunch.createTokenInfoAndMetadata({...}); // Success - result contains the response data directly} catch (error) { // The SDK automatically throws errors for API failures // Error messages contain details about what went wrong console.error('Error:', error.message); // You can check error properties if available if (error.status) { console.error('Status:', error.status); }}
The SDK automatically handles the success: false responses and throws errors, so you don’t need to manually check the success field. Successful responses return the data directly from the response field.