Skip to main content

Try it Live

Run ENS examples in the interactive playground

ENS Errors

Which functions throw

Every ENSIP-15 failure surfaces as DisallowedCharacterError, including script mixtures, confusables, empty labels, and label extensions. The specific reason is in error.cause.message.

DisallowedCharacterError

Extends InvalidFormatError → ValidationError → PrimitiveError → AbstractError → Error.

Reading the reason

The library’s messages may also contain U+200E (left-to-right mark) after quoted labels. Match on substrings, not whole messages. Reasons observed from @adraffy/ens-normalize 1.11.1: These strings come from the third-party library and can change between its versions. Do not build control flow on exact wording.

Matching the error

Use instanceof or name. Do not use _tag: it is "InvalidFormatError" for every Ens error class.

Exported but not thrown

The module also exports five error classes with the same constructor shape and the same base class. No Ens function throws them today; they exist so callers can construct ENSIP-15-specific errors. All default code to -32602.
catch (e) { if (e instanceof Ens.IllegalMixtureError) ... } never matches an error from normalize(). Catch DisallowedCharacterError and inspect cause.message.

Constructor options

Every Ens error class accepts:

See Also