Skip to main content

Error types

Public error classes, their stable fields, common symptoms, and recovery steps.

Nuxt Email exposes five runtime error classes from @lupinum/nuxt-email/errors. Original render failures remain available through cause.

Public errors

ErrorWhen it occursStable fieldsWhat to do
EmailRenderErrorLoading, prop validation, Vue server rendering, document validation, or plain-text conversion fails.templateName; original failure on causeLog the error and inspect cause. Fix the template, props, or document named by templateName.
UnknownEmailTemplateErrorAn untyped runtime name is absent from the generated registry.requestedName; sorted knownNamesUse one of knownNames, or add the template and run nuxt prepare.
TailwindMissingHeadErrorA Tailwind media-query or pseudo-class rule has no <head> inside its ETailwind boundary.Message names the affected classes.Move EHead inside ETailwind, or remove the classes that require head CSS.
DefineEmailOutsideRenderErrordefineEmail() runs outside an email render.Error identity and messageCall it from an email template rendered by Nuxt Email.
DuplicateEmailDefinitionErrorOne render calls defineEmail() more than once.Error identity and messageKeep one call and combine its subject and text metadata.

EmailRenderError.templateName is the registry name for renderEmail(). Standalone rendering uses the Vue component name. There is no componentName compatibility alias.

Find an error by symptom

Search phrase or symptomErrorNext check
Template not found, unknown template, or unknown emailUnknownEmailTemplateErrorCompare requestedName with knownNames. Nested names use / and omit .vue.
Missing head, <head> not found, or Tailwind variant failureTailwindMissingHeadErrorConfirm that EHead is inside the same ETailwind boundary.
defineEmail outside renderDefineEmailOutsideRenderErrorKeep the call in the template's <script setup>.
Duplicate email definitionDuplicateEmailDefinitionErrorSearch the template and its setup path for a second call.
Render failed, invalid document, or invalid propsEmailRenderErrorInspect error.cause; it preserves the underlying failure.

There is no TemplateNotFoundError. The public class for that condition is UnknownEmailTemplateError.

Imports

ts
import {
  DefineEmailOutsideRenderError,
  DuplicateEmailDefinitionError,
  EmailRenderError,
  TailwindMissingHeadError,
  UnknownEmailTemplateError,
} from '@lupinum/nuxt-email/errors'

EmailRenderError is also exported by @lupinum/nuxt-email/testing. The two metadata errors are also exported by @lupinum/nuxt-email/define-email.

Template discovery can report DuplicateEmailTemplateError or EmailTemplateDiscoveryError during module setup. These are diagnostics, not exports from the public error entry point.

Production handling

Log the full error on the server, including cause. Return a generic response to the caller. Nuxt Email does not serialize filesystem paths or stacks into production responses. The development preview shows richer local details for authoring.

server/api/welcome.get.ts
export default defineEventHandler(async () => {
  try {
    return await renderEmail('welcome', props)
  }
  catch (error) {
    console.error(error)
    throw createError({ statusCode: 500, statusMessage: 'Email render failed' })
  }
})