@anzaui/engine - v0.6.0
    Preparing search index...

    Class AnzaError

    The only error type the engine throws (or rejects with). Branch on code, not on the message: messages are for logs and may change.

    The message is prefixed with the code, e.g. [Anza:NOT_FOUND] Page not found. Error messages never contain the request route, absolute file paths or key material.

    import { AnzaError, Page, htmlResponse } from '@anzaui/engine';

    try {
    return htmlResponse(await new Page(url.pathname).run(engine));
    } catch (err) {
    if (err instanceof AnzaError && err.code === 'NOT_FOUND') {
    return new Response('Not Found', { status: 404 });
    }
    if (err instanceof AnzaError && err.code === 'VALIDATION') {
    return new Response('Bad Request', { status: 400 });
    }
    throw err;
    }

    Hierarchy

    • Error
      • AnzaError
    Index
    code: ErrorCode

    The error category. Stable across releases and engines.