From af72a96b7c1226a8fb159268657bce611335b148 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 15 Oct 2026 10:24:27 -0700 Subject: [PATCH] Errors module has no imports, so revert custom error location for better expectations. --- src/lib/errors.ts | 13 ++++++++++++- src/lib/primordials.ts | 26 ++------------------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/lib/errors.ts b/src/lib/errors.ts index b417634..d33333a 100644 --- a/src/lib/errors.ts +++ b/src/lib/errors.ts @@ -1,7 +1,18 @@ //! SPDX-FileCopyrightText: 2026 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { Nano25519WasmError, } from './primordials' +export class Nano25519MutexError extends Error { } +Object.defineProperty(Nano25519MutexError, 'name', { value: 'Nano25519MutexError' }) +Object.freeze(Nano25519MutexError) +export class Nano25519RangeError extends RangeError { } +Object.defineProperty(Nano25519RangeError, 'name', { value: 'Nano25519RangeError' }) +Object.freeze(Nano25519RangeError) +export class Nano25519TypeError extends TypeError { } +Object.defineProperty(Nano25519TypeError, 'name', { value: 'Nano25519TypeError' }) +Object.freeze(Nano25519TypeError) +export class Nano25519WasmError extends Error { } +Object.defineProperty(Nano25519WasmError, 'name', { value: 'Nano25519WasmError' }) +Object.freeze(Nano25519WasmError) /** * Message text for the codes in `src/assembly/errors.ts`. The numbers are the diff --git a/src/lib/primordials.ts b/src/lib/primordials.ts index f73e0fa..961b393 100644 --- a/src/lib/primordials.ts +++ b/src/lib/primordials.ts @@ -1,6 +1,8 @@ //! SPDX-FileCopyrightText: 2026 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { Nano25519RangeError, Nano25519TypeError, } from './errors' + /** * Builtins captured once, when this module is evaluated, so that nothing on a * call path resolves a global or a prototype method that hostile code could @@ -42,30 +44,6 @@ const objectCreate = Object.create export const objectDefineProperty = Object.defineProperty export const objectFreeze = Object.freeze -/** Custom errors */ -class Nano25519MutexError extends Error { } -objectDefineProperty(Nano25519MutexError, 'name', { value: 'Nano25519MutexError' }) -objectFreeze(Nano25519MutexError) - -class Nano25519RangeError extends RangeError { } -objectDefineProperty(Nano25519RangeError, 'name', { value: 'Nano25519RangeError' }) -objectFreeze(Nano25519RangeError) - -class Nano25519TypeError extends TypeError { } -objectDefineProperty(Nano25519TypeError, 'name', { value: 'Nano25519TypeError' }) -objectFreeze(Nano25519TypeError) - -class Nano25519WasmError extends Error { } -objectDefineProperty(Nano25519WasmError, 'name', { value: 'Nano25519WasmError' }) -objectFreeze(Nano25519WasmError) - -export { - Nano25519MutexError, - Nano25519RangeError, - Nano25519TypeError, - Nano25519WasmError -} - /** Type aliases for legibility. */ export type Bytes = Uint8Array export type Words = Uint32Array -- 2.52.0