Error Handling

Every VeloraClient method throws a VeloraError when the server responds with a non-2xx status. VeloraError extends Error and carries the HTTP status code and the parsed response body.

VeloraError#

Class definition
class VeloraError extends Error {
  /** HTTP status code, e.g. 400, 401, 403, 404, 500 */
  status: number

  /** Parsed server response body */
  body: {
    error?: string    // machine-readable error key
    msg?: string      // human-readable message
    [key: string]: any
  } | null
}

Basic catch#

ts
import { VeloraClient, VeloraError } from '@rimora/velora'
import fetch from 'node-fetch'

const client = new VeloraClient({
  apiKey: process.env.VELORA_API_KEY,
  fetch: fetch as any
})

try {
  const job = await client.getJob('non-existent-id')
} catch (err) {
  if (err instanceof VeloraError) {
    console.error('API error', err.status, err.body?.error, err.body?.msg)
  } else {
    throw err // re-throw unexpected errors
  }
}

Switch on status#

ts
import { VeloraError } from '@rimora/velora'

try {
  await client.createJob({ ... })
} catch (err) {
  if (!(err instanceof VeloraError)) throw err

  switch (err.status) {
    case 400:
      console.error('Validation error:', err.body?.msg)
      break
    case 401:
      console.error('Auth failed — check your API key')
      break
    case 403:
      if (err.body?.error === 'insufficient_scope') {
        console.error('API key is missing required scope:', err.body?.msg)
      } else if (err.body?.error === 'job_limit_exceeded') {
        console.error('Plan job limit reached — upgrade your subscription')
      }
      break
    case 404:
      console.error('Job not found')
      break
    default:
      console.error('Unexpected error:', err.status, err.body)
  }
}

Common error codes#

Statuserror keyCause
400validation_errorRequired field missing, invalid cron expression, or blocked target URL
401api_key_missingAuthorization header absent or malformed
401invalid_api_keyKey not found or revoked
403insufficient_scopeKey lacks the required scope for this action
403job_limit_exceededPlan job limit reached
404not_foundResource does not exist or belongs to another account
500db_errorTemporary database error — safe to retry

Network errors#

If the fetch itself fails (DNS, TLS, timeout), the underlying fetch error is thrown directly — it will not be a VeloraError. Catch Error instances separately and inspect err.message.

ts
try {
  await client.listJobs()
} catch (err) {
  if (err instanceof VeloraError) {
    // server replied with non-2xx
  } else if (err instanceof Error) {
    // network-level: DNS, TLS, timeout
    console.error('Network error:', err.message)
  }
}
Node.js TLS errors (e.g. ERR_MODULE_NOT_FOUND, tlsv1 unrecognized name) are network-level and indicate a TLS SNI mismatch. Pass a custom https.Agent with servername set — see the Configuration guide.

© 2026 Velora · API Documentation