From 2b099263d5886742c35b005267efbc130a4c52c3 Mon Sep 17 00:00:00 2001 From: Mauricio Mourraille Date: Thu, 3 Sep 2026 16:28:26 +0200 Subject: [PATCH] docs(readme): fix Error Handling import to use Brevo namespace UnauthorizedError and TooManyRequestsError (and the other per-status error subclasses) are exported under the Brevo namespace (namespaceExport: Brevo), not as top-level named exports. The documented example imported them directly, which fails to compile. Fixes #93 Co-Authored-By: Claude Sonnet 5 --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a8d457f..69ec8d1 100644 --- a/README.md +++ b/README.md @@ -67,14 +67,14 @@ const brevo = new BrevoClient({ The SDK throws specific error types based on HTTP status codes. ```typescript -import { BrevoError, UnauthorizedError, TooManyRequestsError } from '@getbrevo/brevo'; +import { Brevo, BrevoError } from '@getbrevo/brevo'; try { await brevo.transactionalEmails.sendTransacEmail({...}); } catch (err) { - if (err instanceof UnauthorizedError) { + if (err instanceof Brevo.UnauthorizedError) { console.error('Invalid API key'); - } else if (err instanceof TooManyRequestsError) { + } else if (err instanceof Brevo.TooManyRequestsError) { const retryAfter = err.rawResponse.headers['retry-after']; console.error(`Rate limited. Retry after ${retryAfter} seconds`); } else if (err instanceof BrevoError) { @@ -83,14 +83,16 @@ try { } ``` +Typed subclasses are namespaced under `Brevo` (e.g. `Brevo.UnauthorizedError`) — only `BrevoError` and `BrevoTimeoutError` are top-level exports. + **Error Types:** -- `400` - `BadRequestError` -- `401` - `UnauthorizedError` -- `403` - `ForbiddenError` -- `404` - `NotFoundError` -- `422` - `UnprocessableEntityError` -- `429` - `TooManyRequestsError` -- `500+` - `InternalServerError` +- `400` - `Brevo.BadRequestError` +- `401` - `Brevo.UnauthorizedError` +- `403` - `Brevo.ForbiddenError` +- `404` - `Brevo.NotFoundError` +- `422` - `Brevo.UnprocessableEntityError` +- `429` - `Brevo.TooManyRequestsError` +- `500+` - `Brevo.InternalServerError`
Error properties