Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Friendlier error message than `FileNotFoundError`

未关闭
#25 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
cli

调研方向

从 sqlrunner/main.py 开始,这里会将输入传递给 main.read_text,然后检查 sqlrunner/main.py 中的 read_text。使用不存在的输入路径运行 SQL Runner,并验证它会报告一条明确指出缺失文件的友好错误,而不会打印 FileNotFoundError 堆栈跟踪。

由索引模型根据 Issue 内容生成。

描述

If the input file doesn't exist, then SQL Runner prints a stack trace. A friendlier error message than FileNotFoundError would be nice.

Running actions: query

jobrunner.run loop started
query: Copying in code from /Users/iaindillingham/Code/opensafely/tpp-database-schema
query: Preparing
query: Executing
query: Logs written to: /Users/iaindillingham/Code/opensafely/tpp-database-schema/metadata/query.log
query: Finalizing
query: Job exited with error code 1
query: Cleaning up container and volume

=> query
   Job exited with error code 1

   log file: metadata/query.log
   outputs:
     (no outputs)

   logs:

     Traceback (most recent call last):
       File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
         return _run_code(code, main_globals, None,
       File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
         exec(code, run_globals)
       File "/app/sqlrunner/__main__.py", line 8, in <module>
         sql_query = main.read_text(args.input)
       File "/app/sqlrunner/main.py", line 37, in read_text
         return f_path.read_text(encoding="utf-8")
       File "/usr/lib/python3.10/pathlib.py", line 1134, in read_text
         with self.open(mode='r', encoding=encoding, errors=errors) as f:
       File "/usr/lib/python3.10/pathlib.py", line 1119, in open
         return self._accessor.open(self, mode, buffering, encoding, errors,
     FileNotFoundError: [Errno 2] No such file or directory: 'analysis/query.sql'
主要语言
Python
星标
1
派生
0
平均合并
8 天 18 小时
30 天内合并 PR
6

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

opensafely-core/sqlrunner 的其他 Issue

查看 opensafely-core/sqlrunner 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。