v9.1.0
envaptClasses

EnvaptError

The error envapt throws. Its code identifies the failure.

Example

try {
  Envapter.require('DATABASE_URL', 'SESSION_SECRET');
} catch (error) {
  if (error instanceof EnvaptError && error.code === EnvaptErrorCodes.MissingEnvValue) {
    console.error(error.message);
    process.exit(1);
  }
  throw error;
}

See

https://envapt.materwelon.dev/docs/errors#the-error-shape

Extends

  • Error

Constructors

Constructor

new EnvaptError(
   code, 
   message, 
   options?
): EnvaptError;

Parameters

ParameterType
codeEnvaptErrorCodes
messagestring
options?EnvaptErrorOptions

Returns

EnvaptError

Overrides

Error.constructor

Properties

PropertyModifierTypeDescriptionInherited from
cause?publicunknown-Error.cause
codereadonlyEnvaptErrorCodesThe EnvaptErrorCodes value identifying what failed.-
issuesreadonlyreadonly EnvaptIssue[] | undefinedPopulated only for EnvaptErrorCodes.SchemaValidationFailed (208) and EnvaptErrorCodes.InvalidEnvValue (210). For every other code this is undefined. If a custom parser or schema throws during a required read, the issue for that key keeps the thrown value as cause. If exactly one issue has a cause, the error's own cause is that value too.-
messagepublicstring-Error.message
namepublicstring-Error.name
stack?publicstring-Error.stack

On this page