explainFailure(packageInput: string,coderName: string,error: unknown): Promise<string>
Explains a failure that only surfaced once the package was imported.
A run reaches import() only when discovery vouched for the coder, or when
discovery was unavailable and the name was taken on trust; either way the
package can still turn out to be unloadable, or the export can still fail to
behave. This runs the listing after the fact and answers with the same
guidance an incomplete invocation would have given, falling back to the raw
error when neither the package nor the coder is at fault — a malformed
input, say.
An UnverifiedArityError is answered without running the listing.
It is raised only on the trusted path, where discovery has already failed
once, and asking again buys nothing but a second wait — up to another thirty
seconds of it when the first attempt timed out.
The guides it renders carry no header: the caller announced the specifier before the run started, and repeating it makes every failure open with the same line twice.
A misspelled coder is answered with the listing and a suggestion
A misspelled coder is answered with the listing and a suggestion
import { assertStringIncludes } from "@std/assert"; import { explainFailure } from "./cli.ts"; const text = await explainFailure( import.meta.resolve("../arp/mod.ts"), "arpDatum", new Error("Coder 'arpDatum' not found"), ); assertStringIncludes(text, "no coder named 'arpDatum'"); assertStringIncludes(text, "did you mean 'arpData'?");