Skip to content

frontend: Replace string-based exceptions with std::runtime_error#13412

Open
gundarapuashwin wants to merge 6 commits intoobsproject:masterfrom
gundarapuashwin:fix/init-exceptions
Open

frontend: Replace string-based exceptions with std::runtime_error#13412
gundarapuashwin wants to merge 6 commits intoobsproject:masterfrom
gundarapuashwin:fix/init-exceptions

Conversation

@gundarapuashwin
Copy link
Copy Markdown

@gundarapuashwin gundarapuashwin commented May 7, 2026

Replace raw const char* throws in initialization with proper std::runtime_error exceptions. This allows localization of error messages and follows C++ best practices.

Fixes #13394

Description

Replaced raw const char* throws in AppInit() with std::runtime_error exceptions. Updated the corresponding catch block in run_program() to catch std::exception instead of const char*.

Motivation and Context

Raw string exceptions cannot be localized and are considered messy error handling. Using proper C++ exception types allows future localization of error messages and follows modern C++ best practices.

How Has This Been Tested?

Ran clang-format-19 locally to ensure style compliance. CI builds are running across Ubuntu, macOS, and Windows platforms to verify compilation.

Types of changes- Bug fix (non-breaking change which fixes an issue)

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Ashwin Gundarapu added 2 commits May 7, 2026 11:17
Replace raw const char* throws in initialization with proper
std::runtime_error exceptions. This allows localization of error
messages and follows C++ best practices.

Fixes obsproject#13394
@Warchamp7
Copy link
Copy Markdown
Member

Warchamp7 commented May 7, 2026

Please make sure to fill out each section of the pull request template.

There are also some other string based exceptions within this file that were missed.

@gundarapuashwin
Copy link
Copy Markdown
Author

Please make sure to fill out each section of the pull request template.

There are also some other string based exceptions within this file that were missed.

Edited and fixed the contents you needed

@Warchamp7
Copy link
Copy Markdown
Member

This is also missing the localization portion of the original Task issue. You can see the helper function QTStr in various places of OBSApp.

Note since you're a new contributor, you only have to worry about updating en-US.ini with localization strings. Translations for other languages are automated.

That being said, some of these errors are before the locale is initialized for the purposes of that helper, so it's gonna need some additional thought for tackling that. It may be that we need an initialization specific helper function that uses the Qt locale rather than the user chosen one from the ini.

Ashwin Gundarapu added 2 commits May 8, 2026 13:24
Replace hardcoded exception strings with localized versions
using QTStr(). Add GetInitErrorString helper for errors that
may occur before locale initialization.
@gundarapuashwin
Copy link
Copy Markdown
Author

This is also missing the localization portion of the original Task issue. You can see the helper function QTStr in various places of OBSApp.

Note since you're a new contributor, you only have to worry about updating en-US.ini with localization strings. Translations for other languages are automated.

That being said, some of these errors are before the locale is initialized for the purposes of that helper, so it's gonna need some additional thought for tackling that. It may be that we need an initialization specific helper function that uses the Qt locale rather than the user chosen one from the ini.

done, please check it.

@WizardCM WizardCM added the kind/cleanup Non-breaking change which makes code smaller or more readable label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Non-breaking change which makes code smaller or more readable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate string-based exceptions during initialization to localized error codes/types

3 participants