Files

description, kind
description kind
Dependency-free HarnessError base class whose stable code lets tool results, retries, and replay route failures. package-library

@deepseek-ai/dsh-error

English | 中文

Summary

dsh-error holds HarnessError, the base class for every expected Harness failure. A HarnessError carries a stable machine-routable code beside its human-readable message and optional cause, and its name is the constructing class name. The tool registry records name and code of a thrown HarnessError on tool/result, so retry policy, UI, replay, and analytics route on the code instead of parsing text. The package has no dependencies, so packages below dsh-llm in the dependency graph can extend the base too; dsh-llm re-exports the same class.

Table of Contents


Use this package

Extend HarnessError with one class per owning package or domain and give each failure a stable UPPER_SNAKE_CASE code:

import { HarnessError } from '@deepseek-ai/dsh-error'

export class ArchiveError extends HarnessError {}

throw new ArchiveError('archive entry is missing', 'ARCHIVE_ENTRY_NOT_FOUND')

Assign this.name a string literal in a subclass constructor when a bundler could rename the class, because name is persisted. Import the class from @deepseek-ai/dsh-error or from its @deepseek-ai/dsh-llm re-export; both name the same class, so instanceof checks agree. The error class and code guide defines class choice, naming, and code conventions.


Understand the implementation

Implementation internals — click to expand

Source map

File Role
src/index.ts The HarnessError base class

Why it stays dependency-free

dsh-llm depends on lower packages such as dsh-attachment and dsh-typert-protocol, so a base class defined there could not be extended below it without a dependency cycle. Keeping the class in a package without dependencies lets every package extend it; the decision note records the relocation.


Further Exploration


Dev Note

Working context for maintainers — click to expand

None.