Files
deepseek-harness/packages/llm/src/error.ts
T
Tianyi Cui 7c400e9c02 docs: unify ADR/RFC trees into one lifecycle-organized RFC tree
Collapse docs/adr/ and docs/rfc/ into a single docs/rfc/ with proposed/,
implemented/, and rejected/ subfolders. Every file is renamed to
yyyy-mm-dd-topic-title.md, where the date is when the topic was first
proposed (from git history). ADRs and RFCs that covered exactly the same
topic are merged (property-based testing, session persistence); the
umbrella RFC 005 stays split across its three implemented decisions, and
RFC 006's deferred part-3 (API extractor reports) splits into its own
proposed RFC. All cross-references become machine-checkable relative
links instead of bare "ADR NNNN" / "RFC NNN" prose.

Add a verify-md-links doc-sync gate (scripts/verify-md-links.ts) that
checks every relative Markdown cross-link resolves, wired into doc-sync
alongside verify-md-wrap. This makes the reorganization self-verifying:
the same change that rewrote ~forty inter-doc links adds the check that
proves none dangle. Document the cross-link convention in a new
docs/AGENTS.md and record the gate as an implemented RFC.

doc-sync, typecheck, lint, and the full test suite (667) all pass.
2026-06-18 02:18:24 +08:00

34 lines
1.3 KiB
TypeScript

/**
* The harness error taxonomy: one base class so failures carry a stable,
* machine-routable `code` and chain their `cause`, instead of flattening to a
* bare message string. Per-package errors extend {@link HarnessError}; the
* tool layer surfaces `{ name, code }` on results and the session `tool/result`
* event so retry/sandbox plugins and replay can distinguish failure classes.
*
* Lives in dsh-llm (the leaf package every other imports) so a single base is
* shared without a new dependency edge. See the error-taxonomy RFC.
*
* @module @deepseek-ai/dsh-llm/error
*/
/**
* Base class for all harness errors. Carries a `code` (stable, programmatic —
* e.g. `NO_ADAPTER`, `INVALID_ARGS`, `INVARIANT`) distinct from the
* human-readable `message`, and supports `cause` chaining via the standard
* `ErrorOptions`. `name` defaults to the subclass constructor name.
*/
export class HarnessError extends Error {
readonly code: string
constructor(message: string, code: string, options?: ErrorOptions) {
super(message, options)
this.code = code
this.name = new.target.name
}
}
/** Narrow an arbitrary thrown value to a HarnessError (for `instanceof` at seams). */
export function isHarnessError(value: unknown): value is HarnessError {
return value instanceof HarnessError
}