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
| Parameter | Type |
|---|---|
code | EnvaptErrorCodes |
message | string |
options? | EnvaptErrorOptions |
Returns
EnvaptError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
cause? | public | unknown | - | Error.cause |
code | readonly | EnvaptErrorCodes | The EnvaptErrorCodes value identifying what failed. | - |
issues | readonly | readonly EnvaptIssue[] | undefined | Populated 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. | - |
message | public | string | - | Error.message |
name | public | string | - | Error.name |
stack? | public | string | - | Error.stack |