Niall Douglas wrote: ...
If there was an error, we return an error code of kerneltest_errc::filesystem_comparison_internal_failure with a payload of the string message from the source error and its original error code in the first 32 bit code1 integer. That is used later on to print the exact error code returned by the system as we know it will always be system_category.
If the directory structures differed, we return an error code of kerneltest_errc::filesystem_comparison_failed with a payload of the string of the path which did not match.
Is this sufficient, or would you prefer a different example?
Thanks, that's very helpful. The use case here is similar to std::throw_with_nested, you have an error_code that you are overriding with another. You could extend your ring buffer facility to support this natively. For that, you need to store in the buffer entry the error code (a duplicate of error_code_extended's members) _and_ the unique_id of the "parent" error_info_extended. This would allow you to later retrieve the whole chain of ring buffer entries (subject to availability.) In your example, you'd do testret = error_code_extended( kerneltest_errc::filesystem_comparison_internal_failure, workspaces_not_identical.error() ); Since workspaces_not_identical.error() is already in the ring buffer, you only need a 'pointer' to it in testret. There's also no need to pass its message() in testret's message, you could use that for other purposes.