Files
life-echo/skills/error-handling.md
iammm0 6526c08c3a docs: 新增技能文档
- 新增Skills.md技能说明
- 新增skills/技能文档目录

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 11:30:12 +08:00

28 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Skill错误处理Android
与具体业务无关的 Android 错误展示设计:错误类型、友好文案与组件。
---
## 错误类型
- **ErrorType** 枚举NETWORK、SERVER、TIMEOUT、AUTH、NOT_FOUND、VALIDATION、UNKNOWN。
## ErrorHandler
- `getFriendlyError(errorType, originalMessage)`:生产环境返回友好文案,开发环境可带出 `originalMessage`(如 VALIDATION
- `detectErrorType(exception)`:根据异常 message 关键词推断类型。
- `detectErrorTypeByStatusCode(statusCode)`401/403→AUTH404→NOT_FOUND5xx→SERVER 等。
- `getDisplayMessage` / `handleException`:统一得到最终展示文案。
## 组件
- **FriendlyErrorView**:全屏错误页,图标+标题+描述+重试/去登录按钮,可选动画。
- **FriendlyErrorDialog**:弹窗版,带确认/取消或重试。
- **InlineErrorMessage**:表单等内联错误,生产环境对部分技术性文案做友好替换。
- **Snackbar**`showFriendlyError` 扩展,用于轻量提示。
## 约定
- 生产环境不直接暴露后端异常原文;开发环境可通过 `AppConfig.isDebugMode` 显示原始信息。