Trigger Conditions
Activate this skill when the user pastes or encounters a programming error message (in English) and needs translation and explanation.
Workflow
-
Identify the Error Type
- Determine the programming language and runtime environment (Python/Java/JavaScript/Go/Rust/C/C++, etc.)
- Determine the error type: syntax error, runtime error, compilation error, framework error, system error
-
Translate the Error Message
- Accurately translate the English error message into Chinese
- Preserve key technical terms (class names, function names, file paths)
- Translation format:
原文 → 中文翻译
-
Analyze the Cause of the Error
- Explain the cause of the error in concise Chinese
- Describe common trigger scenarios
- List code patterns that may cause this error
-
Provide Fix Solutions
- Give 2-3 specific fix suggestions
- Include before-and-after code comparison examples
- If there are best practices, explain them as well
Output Format
## 🌐 错误翻译
**原始消息:** `English error message here`
**中文翻译:** 中文翻译内容
## 🔍 错误分析
**错误类型:** [语法错误|运行时错误|编译错误|框架错误]
**发生原因:** 简洁说明为什么会发生这个错误
## 🔧 修复方案
### 方案一(推荐)
修改前:
\`\`\`language
// 有问题的代码
\`\`\`
修改后:
\`\`\`language
// 修复后的代码
\`\`\`
### 方案二
其他可能的解决方案...
## 💡 预防建议
- 避免此类错误的最佳实践
Supported Common Error Types
Python
TypeError,ValueError,KeyError,IndexErrorImportError,ModuleNotFoundErrorAttributeError,FileNotFoundErrorSyntaxError,IndentationError- Django/Flask/FastAPI framework errors
asyncioAsync errorspandas/numpyData processing errors
JavaScript/TypeScript
TypeError,ReferenceError,SyntaxErrorCannot read property of undefinedPromise rejectionerrors- React/Vue/Angular framework errors
- Node.js module and dependency errors
- TypeScript type errors
ESLint/Prettierconfiguration errors
Java
NullPointerException,ClassNotFoundExceptionRuntimeException,IOException- Spring/Hibernate framework errors
- Maven/Gradle build errors
- JVM memory errors (
OutOfMemoryError)
Other Languages
- Go:
nil pointer,index out of range,goroutineleaks - Rust:
borrow checker,lifetimeerrors - C/C++:
segmentation fault,undefined reference, memory leaks - SQL: syntax errors, constraint conflicts, connection pool errors
- PHP:
Undefined variable, namespace errors
Common Error Pattern Examples
Example 1: Python KeyError
Original message: KeyError: 'username'
Chinese translation: 键错误:'username'
Cause analysis: Attempted to access the key 'username' that does not exist in the dictionary
Fix solutions: Use .get('username', default_value) or check whether the key exists
Example 2: JavaScript Cannot read property 'map' of undefined
Original message: TypeError: Cannot read property 'map' of undefined
Chinese translation: 类型错误:无法读取未定义对象的 'map' 属性
Cause analysis: Attempted to call the .map() method on an undefined value
Fix solutions: Add a null check data?.map(...) or ensure the data has been initialized
Example 3: Java NullPointerException
Original message: java.lang.NullPointerException
Chinese translation: 空指针异常
Cause analysis: Attempted to use a null object reference
Fix solutions: Add a null check, use Optional<T>, or check object initialization
Notes
- Maintain the accuracy of technical terms; do not over-translate
- For framework-specific errors, specify which framework it is
- If the error information is incomplete, ask the user to provide the complete traceback
- Prioritize providing safe fix solutions to avoid introducing new problems
- Suggest that users add error monitoring and logging to prevent similar errors