Skip to content

fix: prefer std::filesystem error_code overloads over exceptions#295

Open
hesam-oxe wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
hesam-oxe:fix/filesystem-error-code-noexcept
Open

fix: prefer std::filesystem error_code overloads over exceptions#295
hesam-oxe wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
hesam-oxe:fix/filesystem-error-code-noexcept

Conversation

@hesam-oxe

Copy link
Copy Markdown

Replaced throwing std::filesystem calls with non-throwing error_code
overloads in process_image() and make_output_path().

Changes

  • process_image(): Removed try/catch around std::filesystem::exists(),
    now uses std::filesystem::exists(path, ec) with explicit error_code
    handling
  • make_output_path(): Updated exists() and create_directory() calls
    to use error_code overloads
  • Preserves existing Status::FilesystemError and Status::InputFileNotFound
    behavior

Why

The C++ standard library allows querying filesystem operations with
error_code instead of exceptions. This avoids exception-based control
flow for expected filesystem failures and is consistent with modern
C++ best practices.

Closes #275

hesam-oxe added 2 commits May 10, 2026 08:26
Replaced full-table literals with spot-checks for fixtures and fingerprint verification for transforms. Reduced from ~1900 to ~450 lines. Closes AcademySoftwareFoundation#276
Replaced throwing std::filesystem calls with non-throwing error_code overloads in process_image and make_output_path. Closes AcademySoftwareFoundation#275
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@antond-weta

Copy link
Copy Markdown
Contributor

Thanks for looking into this. I see you included the changes from 278 here. It is better to only have relevant changes in each PR. The 278 was fine, apart from missing the CLA.

Unfortunately we can not accept contributions without a signed CLA. Please get that sorted if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[util] Prefer std::filesystem error_code overloads; noexcept where safe

2 participants