Errors
Common SDK error types when a docs page cannot load content.
Handle SDK errors in route handlers and pages.
import { NotFoundError } from '@elmapicms/js-sdk';
import { notFound } from 'next/navigation';
try {
// fetch article
} catch (error) {
if (error instanceof NotFoundError) notFound();
throw error;
}Typical cases
- NotFoundError: slug missing, never published, or unpublished
- Unauthorized / forbidden: token missing or lacking
read - Validation errors: create/update payloads that fail field rules
For public docs pages, map not-found to a 404 page. Log unexpected errors and fail the request so hosting monitors can catch them.