diff --git a/src/error.ts b/src/error.ts deleted file mode 100644 index 81e7a65..0000000 --- a/src/error.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { NBTData } from "./format.js"; - -export interface NBTErrorOptions extends ErrorOptions { - byteOffset: number; - cause: NBTData; - remaining: number; -} - -export class NBTError extends Error { - byteOffset: number; - override cause: NBTData; - remaining: number; - - constructor(message: string, options: NBTErrorOptions) { - super(message, options); - this.byteOffset = options.byteOffset; - this.cause = options.cause; - this.remaining = options.remaining; - } -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 8411ade..1481f7e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,5 +5,4 @@ export * from "./stringify.js"; export * from "./format.js"; export * from "./tag.js"; export * from "./primitive.js"; -export * from "./error.js"; export * from "./compression.js"; \ No newline at end of file diff --git a/src/read.ts b/src/read.ts index ac5645c..1bfba30 100644 --- a/src/read.ts +++ b/src/read.ts @@ -3,7 +3,6 @@ import { NBTData } from "./format.js"; import { Int8, Int16, Int32, Float32 } from "./primitive.js"; import { TAG, TAG_TYPE, isTagType } from "./tag.js"; import { decompress } from "./compression.js"; -import { NBTError } from "./error.js"; import type { RootName, Endian, Compression, BedrockLevel } from "./format.js"; import type { Tag, RootTag, RootTagLike, ByteTag, ShortTag, IntTag, LongTag, FloatTag, DoubleTag, StringTag, ByteArrayTag, ListTag, CompoundTag, IntArrayTag, LongArrayTag } from "./tag.js"; @@ -179,7 +178,7 @@ class NBTReader { if (strict && this.#data.byteLength > this.#byteOffset) { const remaining: number = this.#data.byteLength - this.#byteOffset; - throw new NBTError(`Encountered unexpected End tag at byte offset ${this.#byteOffset}, ${remaining} unread bytes remaining`, { byteOffset: this.#byteOffset, cause: new NBTData(root as RootTag, { rootName: rootNameV, endian }), remaining }); + throw new Error(`Encountered unexpected End tag at byte offset ${this.#byteOffset}, ${remaining} unread bytes remaining`); } return new NBTData(root, { rootName: rootNameV, endian, compression, bedrockLevel });