mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 08:32:00 +00:00
fix: tighten target error hint coverage
This commit is contained in:
@@ -19,6 +19,16 @@ describe("target error helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("treats blank hints the same as no hint", () => {
|
||||
expect(missingTargetMessage("Slack", " ")).toBe("Delivering to Slack requires target");
|
||||
expect(ambiguousTargetMessage("Discord", "general", " ")).toBe(
|
||||
'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.',
|
||||
);
|
||||
expect(unknownTargetMessage("Discord", "general", " ")).toBe(
|
||||
'Unknown target "general" for Discord.',
|
||||
);
|
||||
});
|
||||
|
||||
it("formats ambiguous and unknown target messages with labeled hints", () => {
|
||||
expect(ambiguousTargetMessage("Discord", "general")).toBe(
|
||||
'Ambiguous target "general" for Discord. Provide a unique name or an explicit id.',
|
||||
|
||||
@@ -23,8 +23,9 @@ export function unknownTargetError(provider: string, raw: string, hint?: string)
|
||||
}
|
||||
|
||||
function formatTargetHint(hint?: string, withLabel = false): string {
|
||||
if (!hint) {
|
||||
const normalized = hint?.trim();
|
||||
if (!normalized) {
|
||||
return "";
|
||||
}
|
||||
return withLabel ? ` Hint: ${hint}` : ` ${hint}`;
|
||||
return withLabel ? ` Hint: ${normalized}` : ` ${normalized}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user