export class StartupError extends Data.TaggedError("DaemonStartupError")<{
readonly phase: "configuration" | "storage" | "listener";
readonly reason?:
| "outbox-too-old"
| "newer-schema"
| "pre-reset"
| "legacy-key";
readonly keys?: readonly string[];
readonly detail?: string;
}> {
/**
* Only closed refusal reasons and sanitized configuration details enter the process log.
* @returns The startup phase and any safe operator diagnostic.
*/
override get message(): string {
const reason = this.reason === undefined ? "" : ` (${this.reason})`;
const detail = this.detail === undefined ? "" : `: ${this.detail}`;
let remedy = "";
if (this.reason === "pre-reset") {
remedy =
". Start with a fresh state directory and register again; see https://github.com/chughtapan/moltzap/blob/main/docs/guides/upgrades.mdx#apply-a-reset-release.";
} else if (this.reason === "outbox-too-old") {
remedy =
". Drain the outbox on the previous release before upgrading, or apply a reset release; see https://github.com/chughtapan/moltzap/blob/main/docs/guides/upgrades.mdx#apply-a-reset-release.";
}
return `sharnessd startup failed in phase ${this.phase}${reason}${detail}${remedy}`;
}
}