mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 20:24:03 +00:00
22 lines
804 B
TypeScript
22 lines
804 B
TypeScript
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
|
|
export function formatMatrixErrorMessage(err: unknown): string {
|
|
return formatErrorMessage(err);
|
|
}
|
|
|
|
export function formatMatrixErrorReason(err: unknown): string {
|
|
return normalizeLowercaseStringOrEmpty(formatMatrixErrorMessage(err));
|
|
}
|
|
|
|
export function isMatrixNotFoundError(err: unknown): boolean {
|
|
const errObj = err as { statusCode?: number; body?: { errcode?: string } };
|
|
if (errObj?.statusCode === 404 || errObj?.body?.errcode === "M_NOT_FOUND") {
|
|
return true;
|
|
}
|
|
const message = formatMatrixErrorReason(err);
|
|
return (
|
|
message.includes("m_not_found") || message.includes("[404]") || message.includes("not found")
|
|
);
|
|
}
|