mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 05:20:46 +08:00
fix: surface actionable channel message errors
This commit is contained in:
parent
b42fc411c2
commit
7cbed3aefb
59 changed files with 2405 additions and 607 deletions
17
plugin-src/client/last-message-error.js
Normal file
17
plugin-src/client/last-message-error.js
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue