Error Rosetta
"The Rosetta Stone let scholars read Egyptian hieroglyphics by providing the same text in three languages. Your compiler already speaks three languages — the error code, the stack trace, and the actual problem. It just refuses to use the third one."
What It Does
You see this:
CODEBLOCK0
Error Rosetta gives you this:
CODEBLOCK1
The Translation Layers
Layer 1: Error Identification
Every error message, no matter how cryptic, contains these decodable components:
| Component | What It Tells You | Example |
|---|
| Error Type | Category of problem | INLINECODE0 , ENOENT, HTTP 422, INLINECODE3 |
| Error Message |
What went wrong (usually poorly) | "Cannot read properties of undefined" |
|
Location | Where it happened | File path + line number |
|
Stack Trace | How it got there | Call chain from entry point to error |
|
Error Code | Machine-readable identifier |
E0308,
TS2345,
EPERM |
Layer 2: Context Enrichment
Raw error → enriched with your codebase context:
CODEBLOCK2
Layer 3: Plain Language Translation
The enriched error is translated into three outputs:
CODEBLOCK3
Error Pattern Library
JavaScript/TypeScript
| Cryptic Error | Plain Translation | Common Fix |
|---|
| INLINECODE7 | You're accessing .x on something that doesn't exist | Add optional chaining ?.x or check for null/undefined first |
| INLINECODE10 |
You're calling something that isn't callable — it's a value, not a function | Check: did you forget
() on a prior call? Is the import correct? |
|
Maximum call stack size exceeded | Infinite recursion — a function calls itself forever | Find the recursive call missing its base case |
|
Cannot assign to 'x' because it is a read-only property | You're mutating something that shouldn't be mutated | Use spread/Object.assign to create a new object instead |
|
Module not found: Can't resolve 'x' | Import path is wrong or package isn't installed | Check spelling, check node_modules, run npm install |
|
TS2345: Argument of type 'X' is not assignable to parameter of type 'Y' | Type mismatch — you're passing the wrong shape of data | Check what the function expects vs. what you're giving it |
Python
| Cryptic Error | Plain Translation | Common Fix |
|---|
| INLINECODE16 | A function returned None when you expected an object | The function upstream returned nothing — check its return paths |
| INLINECODE17 |
Whitespace is wrong (tabs vs. spaces or wrong level) | Fix indentation — use consistent spaces |
|
RecursionError: maximum recursion depth exceeded | Infinite recursion | Find the missing base case in your recursive function |
|
KeyError: 'x' | You're accessing a dictionary key that doesn't exist | Use
.get('x', default) or check
if 'x' in dict first |
|
ImportError: cannot import name 'x' from 'y' | The thing you're importing doesn't exist in that module | Check spelling, check the module's
__init__.py, check version |
Rust
| Cryptic Error | Plain Translation | Common Fix |
|---|
| INLINECODE24 | You used a value after giving ownership to something else | Clone it, use a reference, or restructure to avoid the move |
| INLINECODE25 |
Expected one type, got another | Check your function signatures and return types |
|
E0502: cannot borrow 'x' as mutable because it is also borrowed as immutable | You have a read reference and are trying to write | Restructure to not hold both borrows simultaneously |
|
E0106: missing lifetime specifier | Rust can't figure out how long a reference should live | Add explicit lifetime annotations |
Go
| Cryptic Error | Plain Translation | Common Fix |
|---|
| INLINECODE28 | Type mismatch in assignment or function call | Check the expected type and convert |
| INLINECODE29 |
Using a name that doesn't exist in this scope | Check import, check spelling, check scope |
|
fatal error: all goroutines are asleep - deadlock! | Every goroutine is waiting for something and nothing can proceed | Check channel operations — something isn't sending or receiving |
|
panic: runtime error: index out of range | Array/slice access beyond its length | Check bounds before accessing |
System/OS Errors
| Cryptic Error | Plain Translation | Common Fix |
|---|
| INLINECODE32 | File or directory doesn't exist at that path | Check the path — typo? Missing directory? Relative vs absolute? |
| INLINECODE33 |
You don't have permission to access this | Check file permissions, check if you need sudo/admin |
|
EADDRINUSE: address already in use | Another process is already using that port | Kill the other process or use a different port |
|
ENOMEM: not enough memory | System is out of memory | Check for memory leaks, increase available memory, or reduce consumption |
|
ETIMEDOUT: connection timed out | The remote host didn't respond in time | Check network, check if the service is running, check firewall |
HTTP Errors
| Code | What The Server Actually Means | Developer Action |
|---|
| INLINECODE37 | "Your request is malformed — I can't even parse it" | Check request body format, content-type header, required fields |
| INLINECODE38 |
"Who are you? I don't see valid credentials" | Check auth token, check if it's expired, check the auth header format |
|
403 Forbidden | "I know who you are. You're not allowed" | Check permissions/roles, check if the resource requires different access |
|
404 Not Found | "That URL doesn't point to anything" | Check the URL path, check if the resource exists, check API version |
|
409 Conflict | "This conflicts with the current state" | Check for duplicate resources, check version/ETag conflicts |
|
422 Unprocessable Entity | "I can read your request but the data doesn't make sense" | Check validation rules, check field values against API docs |
|
429 Too Many Requests | "Slow down. You're hitting the rate limit" | Add backoff/retry logic, check rate limit headers |
|
500 Internal Server Error | "Something broke on my end, not your fault" | Check server logs, it's a bug in the backend |
|
502 Bad Gateway | "I'm a proxy and the server behind me is broken" | Check the upstream service, check proxy config |
|
503 Service Unavailable | "I'm overloaded or doing maintenance" | Retry with backoff, check status page |
The Translation Process
CODEBLOCK4
Output Format
CODEBLOCK5
When to Invoke
- - Every time you see an error you don't immediately understand. That's the whole point.
- When onboarding in a new language or framework (the error messages are a new dialect)
- When the error is in a dependency's code and you need to understand what YOU did wrong
- When debugging a CI failure with a wall of log output
- When a user reports an error and you need to decode it fast
Why It Matters
Developers spend 35-50% of their time debugging. A significant portion of that time is spent understanding what the error message is telling them — not fixing the actual bug. The faster you decode the message, the faster you fix the problem.
Error Rosetta doesn't fix bugs. It removes the translation step between seeing the error and understanding the error. Everything after that is just typing.
Zero external dependencies. Zero API calls. Pure pattern matching and code analysis.
错误罗塞塔
罗塞塔石碑通过提供三种语言的同一文本,让学者能够读懂埃及象形文字。你的编译器已经会说三种语言——错误代码、堆栈跟踪和实际问题。它只是拒绝使用第三种。
它的作用
你看到这个:
TypeError: Cannot read properties of undefined (reading map)
at UserList (webpack-internal:///./src/components/UserList.tsx:14:23)
at renderWithHooks (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:14985:18)
at mountIndeterminateComponent (webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:17811:13)
错误罗塞塔给你这个:
通俗解释:你的 UserList 组件试图在某个还不存在的东西上调用 .map()。
在第14行,你访问了一个未定义的属性——很可能是因为组件首次渲染时,
数据还没有从 API 加载完成。
根本原因:src/components/UserList.tsx:14 访问了 users.map()
但 users 在首次渲染时是 undefined。你用来获取 users 的 useEffect
还没有执行完毕。
修复方法:在映射之前添加守卫:
{users?.map(...)} 或 {users && users.map(...)}
更好的做法:用空数组初始化状态:
const [users, setUsers] = useState([]);
翻译层级
第一层:错误识别
每个错误信息,无论多么晦涩,都包含这些可解码的组成部分:
| 组成部分 | 它告诉你什么 | 示例 |
|---|
| 错误类型 | 问题的类别 | TypeError、ENOENT、HTTP 422、SegFault |
| 错误消息 |
出了什么问题(通常表述不佳) | Cannot read properties of undefined |
|
位置 | 发生在哪里 | 文件路径 + 行号 |
|
堆栈跟踪 | 如何到达那里 | 从入口点到错误的调用链 |
|
错误代码 | 机器可读的标识符 | E0308、TS2345、EPERM |
第二层:上下文丰富
原始错误 → 用你的代码库上下文丰富:
丰富过程:
├── 读取错误引用的文件 + 行
├── 理解代码试图做什么(不仅仅是哪里失败了)
├── 检查数据流:undefined/null/错误类型的值从哪里来?
├── 检查最近的更改:最近的提交是否引入了这个?
├── 检查模式:这个错误是否匹配该框架/语言的已知模式?
└── 检查同类问题:其他地方是否也发生类似错误?
第三层:通俗语言翻译
丰富后的错误被翻译成三种输出:
- 1. 发生了什么(一句话,无术语)
你的代码在列表加载之前就试图使用用户列表。
- 2. 为什么会发生(根本原因,在你的代码库中)
useState(undefined) + useEffect(async fetch) = 首次渲染时 undefined。
- 3. 如何修复(针对你的代码,而非通用建议)
第8行:将 useState() 改为 useState([])
错误模式库
JavaScript/TypeScript
| 晦涩错误 | 通俗翻译 | 常见修复 |
|---|
| Cannot read properties of undefined (reading x) | 你在一个不存在的东西上访问 .x | 添加可选链 ?.x 或先检查 null/undefined |
| x is not a function |
你调用了不可调用的东西——它是一个值,不是函数 | 检查:是否忘记在前一个调用上加 ()?导入是否正确? |
| Maximum call stack size exceeded | 无限递归——函数无限地调用自身 | 找到缺少终止条件的递归调用 |
| Cannot assign to x because it is a read-only property | 你在修改不应该被修改的东西 | 使用展开/Object.assign 创建新对象 |
| Module not found: Cant resolve x | 导入路径错误或包未安装 | 检查拼写,检查 node_modules,运行 npm install |
| TS2345: Argument of type X is not assignable to parameter of type Y | 类型不匹配——你传入了错误形状的数据 | 检查函数期望什么 vs. 你给了什么 |
Python
| 晦涩错误 | 通俗翻译 | 常见修复 |
|---|
| AttributeError: NoneType object has no attribute x | 函数返回了 None,但你期望一个对象 | 上游函数没有返回任何东西——检查其返回路径 |
| IndentationError: unexpected indent |
空白符错误(制表符 vs. 空格或错误层级) | 修复缩进——使用一致的空格 |
| RecursionError: maximum recursion depth exceeded | 无限递归 | 找到递归函数中缺少的终止条件 |
| KeyError: x | 你访问了一个不存在的字典键 | 使用 .get(x, default) 或先检查 if x in dict |
| ImportError: cannot import name x from y | 你要导入的东西在该模块中不存在 | 检查拼写,检查模块的
init.py,检查版本 |
Rust
| 晦涩错误 | 通俗翻译 | 常见修复 |
|---|
| E0382: borrow of moved value: x | 你在将所有权转移给其他东西后使用了该值 | 克隆它,使用引用,或重构以避免移动 |
| E0308: mismatched types |
期望一种类型,得到另一种 | 检查函数签名和返回类型 |
| E0502: cannot borrow x as mutable because it is also borrowed as immutable | 你有一个读引用并试图写入 | 重构以不同时持有两个借用 |
| E0106: missing lifetime specifier | Rust 无法确定引用应该存活多久 | 添加显式的生命周期注解 |
Go
| 晦涩错误 | 通俗翻译 | 常见修复 |
|---|
| cannot use x (type Y) as type Z | 赋值或函数调用中的类型不匹配 | 检查期望类型并进行转换 |
| undefined: x |
使用了该作用域中不存在的名称 | 检查导入,检查拼写,检查作用域 |
| fatal error: all goroutines are asleep - deadlock! | 每个 goroutine 都在等待某些东西,没有任何东西可以继续 | 检查通道操作——某些东西没有发送或接收 |
| panic: runtime error: index out of range | 数组/切片访问超出其长度 | 在访问前检查边界 |
系统/操作系统错误
| 晦涩错误 | 通俗翻译 | 常见修复 |
|---|
| ENOENT: no such file or directory | 该路径下文件或目录不存在 | 检查路径——拼写错误?缺少目录?相对路径 vs. 绝对路径? |
| EACCES: permission denied |
你没有访问权限 | 检查文件权限,检查是否需要 sudo/管理员权限 |
| EADDRINUSE: address already in use | 另一个进程已经在使用该端口 | 杀死另一个进程或使用不同的端口 |
| ENOMEM: not enough memory | 系统内存不足 | 检查内存泄漏,增加可用内存,或减少消耗 |
| ETIMEDOUT: connection timed out | 远程主机没有及时响应 | 检查网络,检查服务是否运行,检查防火墙 |
HTTP 错误
| 状态码 | 服务器实际含义 | 开发者操作 |
|---|
| 400 Bad Request | 你的请求格式错误——我甚至无法解析它 | 检查请求体格式、content-type 头、必填字段 |
| 401 Unauthorized |
你是谁?我没有看到有效的凭据 | 检查认证令牌,检查是否过期,检查认证头格式 |
| 403 Forbidden | 我知道你是谁。但你不被允许 | 检查权限/角色,检查资源是否需要不同的访问级别 |
| 404 Not Found | 那个 URL 不指向任何东西 | 检查 URL 路径,检查资源是否存在,检查 API 版本 |
| 409 Conflict | 这与当前状态冲突 | 检查重复资源,检查版本/ETag 冲突 |
| 422 Unprocessable Entity | 我能读取你的请求,但数据没有意义 | 检查验证规则,对照 API 文档检查字段值 |
| 429 Too Many Requests | 慢点。你触发了速率限制 | 添加退避/重试逻辑,检查速率限制头 |
| 500 Internal Server Error | 我这边出了问题,不是你的错 | 检查服务器日志,这是后端的 bug |
| 502 Bad Gateway | 我是代理,我后面的服务器坏了 | 检查上游服务,检查代理配置 |
| 503 Service Unavailable | 我过载了或正在维护 | 带退避重试,检查状态页面 |
翻译过程
输入:错误消息、堆栈跟踪或日志输出(