Commet
  • Pricing
Log InTry out
Introduction

Quickstart

Learn

Resources

SDK ReferenceError HandlingTestingCLI

Plugins

Better Auth
DocumentationKnowledge BaseBuild with AIAPI ReferenceWebhooks

Error Handling

Handle errors with automatic retries and typed error classes

Error Classes

import { CommetAPIError, CommetValidationError } from '@commet/node'

try {
  await commet.customers.create({ email: 'invalid' })
} catch (error) {
  if (error instanceof CommetValidationError) {
    console.log(error.validationErrors)
    // { email: ['Invalid email format'] }
  }
  
  if (error instanceof CommetAPIError) {
    console.log(error.statusCode, error.message)
  }
}
ClassUse case
CommetAPIErrorHTTP errors (4xx, 5xx)
CommetValidationErrorInvalid input with field details
CommetErrorBase class for all errors

Automatic Retries

Failed requests retry with exponential backoff (1s → 2s → 4s, max 8s).

Retryable: 408, 429, 500, 502, 503, 504

const commet = new Commet({
  apiKey: process.env.COMMET_API_KEY!,
  retries: 3,  // default
})

Non-Blocking Usage

Don't let tracking errors break your app:

commet.usage.track({
  customerId: 'user_123',
  feature: 'api_calls',
}).catch(console.error)

// Continue without waiting

How is this guide?

SDK Reference

Configuration, environments, and pagination

Testing

Test safely with sandbox environment

On this page

Error Classes
Automatic Retries
Non-Blocking Usage