Skip to content

Refactor Win32Error to use std::system_error#919

Merged
UE4SS merged 6 commits intoUE4SS-RE:mainfrom
Xebeth:feature/sys-error-msg
Aug 19, 2025
Merged

Refactor Win32Error to use std::system_error#919
UE4SS merged 6 commits intoUE4SS-RE:mainfrom
Xebeth:feature/sys-error-msg

Conversation

@Xebeth
Copy link
Copy Markdown
Contributor

@Xebeth Xebeth commented Jun 12, 2025

Description
Refactored the Win32Error class to use std::system_error to avoid platform-specific code
Continuation of #902

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?
I wrote unit tests to ensure the modification doesn't cause any regression

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have added the necessary description of this PR to the changelog, and I have followed the same format as other entries.
  • Any dependent changes have been merged and published in downstream modules.

https://github.com/Re-UE4SS/UEPseudo/pull/140 depends on this

@Xebeth Xebeth changed the title Feature/sys error msg Refactor Win32Error to use std::system_error Jun 12, 2025
@UE4SS
Copy link
Copy Markdown
Collaborator

UE4SS commented Jun 19, 2025

Any particular reason why this is a draft ? What's still to be done ?

@Xebeth Xebeth marked this pull request as ready for review June 19, 2025 20:47
@Xebeth
Copy link
Copy Markdown
Contributor Author

Xebeth commented Jun 19, 2025

It was a draft while I was making the PR for UEPseudo and then I forgot to change it

DEFAULT_ERROR_CATEGORY macro was creating std::error_category objects on certain uses and polluting global namespace. Replaced with inline function that returns a reference to the proper category singleton.

- Replace DEFAULT_ERROR_CATEGORY macro with default_error_category()
- HRESULT macro -> type alias (prevents Windows.h conflicts)
- Removed redundant null checks on m_error_category
- Added noexcept where applicable for optimization
- Added PlatformResultCode typedef for future crossplatform codes
@narknon narknon requested a review from UE4SS June 26, 2025 17:59
Copy link
Copy Markdown
Collaborator

@UE4SS UE4SS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to merge after this if it's been tested and is working.


namespace RC
{
inline const std::error_category& default_error_category() noexcept
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline const std::error_category& default_error_category() noexcept
inline auto default_error_category() noexcept -> const std::error_category&

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Windows installation is borked at the moment. I'll try to rerun the unit tests asap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test suite is all OK.

UE4SS
UE4SS previously approved these changes Aug 19, 2025
@UE4SS UE4SS merged commit 1ac5333 into UE4SS-RE:main Aug 19, 2025
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.

3 participants