iflytek/astron-agent · warning
${(err as Error)?.message || '分享失败,请稍后再试~'}
Error message
${(err as Error)?.message || '分享失败,请稍后再试~'} What it means
handleShare in console/frontend/src/utils/index.ts catches any error thrown while creating an agent share link (the share API request or subsequent copyText step) and surfaces it via message.error, falling back to the generic Chinese message '分享失败,请稍后再试~' when the thrown value has no message property. It is a UI-level aggregation of upstream API failures, not a single error type.
Solutions
- Check the browser network tab for the share API response status and body to find the real cause.
- Refresh/re-login if the response was 401 — expired auth is the most frequent trigger.
- Retry after a moment if the backend returned 5xx or a timeout; confirm the share service is healthy.
- Improve error normalization: use AxiosError.response.data.message or instance of Error checks so users see actionable text.
- Disable the share button while the request is in flight to prevent duplicate failing calls.
Example fix
// before
} catch (err) {
message.error((err as Error)?.message || '分享失败,请稍后再试~');
}
// after
} catch (err: unknown) {
const msg = err instanceof Error
? err.message
: (err as { message?: string })?.message || t('home.shareFailed');
message.error(msg);
console.warn('分享失败:', err);
} Defensive patterns
Strategy: try-catch
Validate before calling
async function shareGuarded(agentId: string) {
if (!agentId) { message.warning('Agent not saved yet'); return false; }
if (!isLoggedIn()) { message.warning('Please sign in to share'); return false; }
return true;
} Type guard
function isErrorWithMessage(err: unknown): err is Error & { message: string } {
return err instanceof Error && typeof err.message === 'string' && err.message.length > 0;
} Try / catch
try {
await handleShare(agent);
} catch (err: unknown) {
const msg = isErrorWithMessage(err) ? err.message : t('home.shareFailed');
message.error(msg);
console.warn('分享失败:', err);
} Prevention
- Check auth state before calling share APIs; re-authenticate on 401.
- Disable the share button while the request is pending.
- Normalize API error bodies into Error objects with user-readable messages.
- Log the full error (console.warn) for diagnosis while showing a friendly toast.
When it happens
Trigger: The shareAgent API call rejects (network failure, 4xx/5xx, auth token expiry, rate limit) or any code between try and catch throws; the catch reads (err as Error)?.message and shows it, defaulting to the generic fallback when message is undefined.
Common situations: Session expired so the share endpoint returns 401; backend unavailable or gateway timeout; the agent isn't shareable due to permission policy; backend returns an error body whose message field is empty so the fallback text shows; non-Error rejection values (plain strings/undefined) causing the fallback.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- workflow.promptDebugger.importResponseInvalid
- space.spaceNameExists
- space.queryFailed
- workflow.promptDebugger.nodeDebugRequestFailed
- useModelContext must be used within a ModelProvider
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/ca2f0a6d074dd5f3.
Report an issue: GitHub.
Appendix: source
Thrown at console/frontend/src/utils/index.ts:649
): Promise<void> => {
try {
// 1. 获取分享key
const res = await getShareAgentKey({
relateType: 0,
relateId: botId,
});
const shareUrl = t('shareModal.shareOriginModal.shareText', {
botName: botName,
origin: window.location.origin,
botId: botId,
shareKey: res.shareAgentKey,
});
// 2. 复制分享链接
copyText({ text: shareUrl, successText: t('home.copyLinkDone') });
} catch (err) {
message.error((err as Error)?.message || '分享失败,请稍后再试~');
console.warn('分享失败:', err);
}
};
/**
* 根据文件类型设置文件图标
*/
const getFileIcon = (file: UploadFileInfo, isLoading?: boolean) => {
const extension = file?.fileName?.split('.')?.pop()?.toLowerCase();
if (isLoading) {
return fileIconConfig.loading;
}
// 遍历所有分类查找文件扩展名
for (const category of Object.values(fileIconConfig)) {
if (category[extension as keyof typeof category]) {
return category[extension as keyof typeof category];
}
}View on GitHub (pinned to 5e758547a8)