Skip to main content
Version: 1.3.1

Class: NameError

Base class for all name-related errors.

A custom error is intended to convey information to the user about a failure, so that it can be addressed programmatically.

A name handling failure is not considered a native error that should cause a program failure. Au contraire, it is expected that a programmer using this utility would consider validating a name using its own business rules. That is not this utility's job to guess those rules. So, the predefined ValidationRules obey some common validation techniques when it comes to sanitizing a personal name. For this reason, the Config.bypass is set to true by default, indicating that those predefined rules should be skipped for the sake of the program.

A programmer may leverage Parser to indicate business-tailored rules if he or she wants this utility to perform those safety checks behind the scenes.

A name error intends to provide useful information about what causes the error and let the user take initiative on what happens next to the given name: reconstructing it or discarding it.

Extends

  • Error

Extended by

Constructors

Constructor

new NameError(source, message?, type?): NameError

Creates an error with a message describing the issue for a name source.

Parameters

source

string | string[]

name input that caused the error

message?

string

describing the failure.

type?

NameErrorType

of error via NameErrorType

Returns

NameError

Overrides

Error.constructor

Properties

cause?

optional cause?: unknown

Inherited from

Error.cause


message

message: string

Inherited from

Error.message


name

name: string

Inherited from

Error.name


source

readonly source: string | string[]


stack?

optional stack?: string

Inherited from

Error.stack


type

readonly type: NameErrorType

Accessors

hasMessage

Get Signature

get hasMessage(): boolean

Whether a message describing the failure exists.

Returns

boolean


sourceAsString

Get Signature

get sourceAsString(): string

The actual source input which caused the error.

Returns

string

Methods

toString()

toString(): string

Returns a string representation of the error.

Returns

string