Improve error handling for render_template() in topgeb
- Dominant language
- SystemVerilog
- Stars
- 3.6k
- Forks
- 1.1k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 141
Description
Topgen uses helper functions called `render_template` like the one below:
```python
# Template render helper
def render_template(template_path: str, rendered_path: Path, **other_info):
template_contents = generate_top(completecfg, name_to_block,
str(template_path), **other_info)
rendered_path.parent.mkdir(exist_ok=True, parents=True)
with rendered_path.open(mode="w", encoding="UTF-8") as fout:
fout.write(template_contents)
```
These functions miss proper error handling if the `open` syscall fails or `generate_top` returns an empty string.
/cc @matutem
Contributor guide
Research direction
Find the topgen implementation of render_template() and inspect how generate_top() results and rendered_path.open() failures are currently handled. Reproduce the empty-output and open-syscall failure cases, then add the requested error handling and verify the relevant topgen checks or tests if present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100