fix: surface actionable channel message errors

This commit is contained in:
xmanrui 2026-08-25 14:54:50 +08:00
parent b42fc411c2
commit 7cbed3aefb
59 changed files with 2405 additions and 607 deletions

View file

@ -0,0 +1,17 @@
function text(value, maxLength) {
if (typeof value !== 'string') return null;
const trimmed = value.trim();
return trimmed ? trimmed.slice(0, maxLength) : null;
}
export function normalizeLastMessageError(value) {
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
const code = text(value.code, 64);
const reason = text(value.reason, 64);
const message = text(value.message, 500);
const referenceId = text(value.referenceId, 40);
const at = Number.isFinite(value.at) ? value.at : null;
return code && reason && message && referenceId && at !== null
? { code, reason, message, referenceId, at }
: null;
}