Skip to content

unacy / UnacyError

Class: UnacyError

Defined in: packages/core/src/errors.ts:25

Base error class for all unacy errors.

Remarks

All unacy-specific errors extend UnacyError, so callers can catch the entire error family with a single catch (e) { if (e instanceof UnacyError) ... } guard while still discriminating by subclass when needed.

Object.setPrototypeOf is called in the constructor to maintain a correct prototype chain in environments that compile to ES5.

Example

typescript
try {
  registry.convert(value, 'Celsius').to('Kelvin');
} catch (e) {
  if (e instanceof UnacyError) {
    console.error('Unit conversion failed:', e.message);
  }
}

Extends

  • Error

Extended by

Constructors

Constructor

ts
new UnacyError(message): UnacyError;

Defined in: packages/core/src/errors.ts:26

Parameters

ParameterType
messagestring

Returns

UnacyError

Overrides

ts
Error.constructor

Properties

PropertyTypeInherited fromDefined in
cause?unknownError.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
messagestringError.messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namestringError.namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?stringError.stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Released under the MIT License.