AcademySoftwareFoundation / AcademySoftwareFoundation/rawtoaces
[util] Prefer std::filesystem error_code overloads; noexcept where safe
- Dominant language
- C++
- Stars
- 193
- Forks
- 65
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 6
Description
## Summary
Prefer **non-throwing** `std::filesystem` overloads (those taking **`std::error_code`**) instead of overloads that throw **`std::filesystem::filesystem_error`**. Then **remove** the **`try`/`catch`** around input existence checks in **`ImageConverter::process_image`**, mapping errors to existing **`Status`** / **`last_error_message`** behaviour. More broadly, apply **`noexcept`** where it is correct and consistent with the project’s style—especially on helpers that cannot throw after this migration.
## Background (for newcomers)
The comment near `process_image` mentions catching filesystem exceptions (e.g. on Windows). The C++ standard library allows querying filesystem operations with an **`error_code`** instead of exceptions. This issue is about **error handling style**: avoid exception-based control flow for expected filesystem failures where possible, keep user-visible errors aligned with current enums/messages, and document any platform nuance.
## Where to look
- `src/rawtoaces_util/image_converter.cpp` — `process_image` try/catch around `std::filesystem::exists`; other `std::filesystem` uses in this file (e.g. output paths, directories).
- `src/rawtoaces_core/rawtoaces_core.cpp` and `src/rawtoaces_core/define.h` — additional `std::filesystem` usage for broader consistency (scope any wide refactor carefully).
- Project C++ standard / CMake — confirm available `` API.
## Suggested direction (not a prescription)
- Replace throwing calls with `error_code` overloads; branch on `ec` instead of `catch`.
- Preserve or improve **`ImageConverter::Status::FilesystemError`** (and messages) when checks fail.
- Audit small helpers for **`noexcept`** where failure is communicated via return/`error_code` only—avoid marking APIs `noexcept` if they can still throw from other operations unless those are removed.
Contributor guide
Research direction
Start with src/rawtoaces_util/image_converter.cpp, especially ImageConverter::process_image and its filesystem calls, then review src/rawtoaces_core/rawtoaces_core.cpp and src/rawtoaces_core/define.h. Confirm the available filesystem API through the project C++ standard and CMake configuration. Done means expected filesystem failures use error_code while preserving FilesystemError and existing messages, with noexcept added only where safe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100