catch and print exception string in ui on main screen creation
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / dumpsyms (push) Blocked by required conditions
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / dumpsyms (push) Blocked by required conditions
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
parent
d8d5b8e9a3
commit
ce0ff0bea9
@ -13,6 +13,8 @@
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme) : _renderer(renderer), _theme(theme) {
|
||||
bool config_loaded {false};
|
||||
@ -301,9 +303,23 @@ Screen* StartScreen::render(float, bool&) {
|
||||
}
|
||||
} else {
|
||||
if (ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) {
|
||||
_error_string.clear();
|
||||
|
||||
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||
return new_screen.release();
|
||||
try {
|
||||
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||
if (!new_screen) {
|
||||
throw std::runtime_error("failed to init main screen.");
|
||||
}
|
||||
return new_screen.release();
|
||||
} catch (const std::exception& e) {
|
||||
_error_string = std::string{"ToxCore/MainScreen creation failed with: "} + e.what();
|
||||
} catch (...) {
|
||||
_error_string = "ToxCore/MainScreen creation failed with unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
if (!_error_string.empty()) {
|
||||
ImGui::TextColored({1.f, 0.5f, 0.5f, 1.f}, "%s", _error_string.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ struct StartScreen final : public Screen {
|
||||
std::string _tox_profile_path {"unnamed-tomato.tox"};
|
||||
std::vector<std::string> queued_plugin_paths;
|
||||
|
||||
std::string _error_string;
|
||||
|
||||
StartScreen(void) = delete;
|
||||
StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme);
|
||||
~StartScreen(void) = default;
|
||||
|
@ -55,7 +55,7 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
|
||||
profile_data.data(),
|
||||
nullptr // TODO: error checking
|
||||
)) {
|
||||
throw std::runtime_error("FAILED to decrypt save file!!!!");
|
||||
throw std::runtime_error("failed to decrypt save file!");
|
||||
}
|
||||
eee(_tox_profile_password);
|
||||
}
|
||||
@ -69,12 +69,12 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
|
||||
|
||||
tox_options_set_experimental_groups_persistence(options, true);
|
||||
|
||||
TOX_ERR_NEW err_new;
|
||||
Tox_Err_New err_new;
|
||||
_tox = tox_new(options, &err_new);
|
||||
tox_options_free(options);
|
||||
if (err_new != TOX_ERR_NEW_OK) {
|
||||
std::cerr << "tox_new failed with error code " << err_new << "\n";
|
||||
throw std::runtime_error{"tox failed"};
|
||||
throw std::runtime_error{std::string{"toxcore creation failed with '"} + tox_err_new_to_string(err_new) + "'"};
|
||||
}
|
||||
|
||||
// no callbacks, use events
|
||||
|
Loading…
x
Reference in New Issue
Block a user