import {
PaymintClient,
PaymintError,
AuthenticationError,
ValidationError,
NotFoundError,
RateLimitError,
NetworkError,
} from '@paymint/node';
try {
const products = await client.products.list();
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof ValidationError) {
console.error('Invalid request:', error.message);
} else if (error instanceof NotFoundError) {
console.error('Resource not found');
} else if (error instanceof RateLimitError) {
console.error('Rate limited. Retry after:', error.retryAfter);
} else if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof PaymintError) {
console.error('Paymint error:', error.message, error.requestId);
} else {
console.error('Unknown error:', error);
}
}