Skip to content

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

Description

@soswow

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.cppprocess_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 <filesystem> 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions