power-grid-model icon indicating copy to clipboard operation
power-grid-model copied to clipboard

[FEATURE] More readable exception types

Open mgovers opened this issue 10 months ago • 1 comments

Describe the feature request

Since C++20, the <format> STL functionality was introduced to improve string formatting:

  • more readable
  • less use of std::to_string (only when strictly necessary)
  • no unnecessary copying between stack and heap

This issue is about replacing the current PowerGridError and derived exceptions' constructor implementations with more readable patterns using formatted strings.

  • For static format patterns, std::format can be used
  • For format patterns that are not compile-time known, std::formatv needs to be used

The documentation on either is relatively clear, so it should not be a hard ticket to pick up.

mgovers avatar Apr 05 '24 08:04 mgovers

It is possible that MacOS needs an additional feature flag before we can use this feature: https://github.com/PowerGridModel/power-grid-model/actions/runs/8570641564/job/23489029489

Note that according to https://en.cppreference.com/w/cpp/compiler_support/20 , the XCode version we use in CI for MacOS (15.2) should support it, so this result was unexpected. See also https://github.com/PowerGridModel/power-grid-model/actions/runs/8570641564/job/23489028931#step:5:36

mgovers avatar Apr 05 '24 13:04 mgovers