catch and print exception string in ui on main screen creation
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
This commit is contained in:
parent
d8d5b8e9a3
commit
ce0ff0bea9
@ -13,6 +13,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme) : _renderer(renderer), _theme(theme) {
|
StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme) : _renderer(renderer), _theme(theme) {
|
||||||
bool config_loaded {false};
|
bool config_loaded {false};
|
||||||
@ -301,9 +303,23 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) {
|
if (ImGui::Button("proceed", {TEXT_PROCEED_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) {
|
||||||
|
_error_string.clear();
|
||||||
|
|
||||||
|
try {
|
||||||
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
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();
|
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::string _tox_profile_path {"unnamed-tomato.tox"};
|
||||||
std::vector<std::string> queued_plugin_paths;
|
std::vector<std::string> queued_plugin_paths;
|
||||||
|
|
||||||
|
std::string _error_string;
|
||||||
|
|
||||||
StartScreen(void) = delete;
|
StartScreen(void) = delete;
|
||||||
StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme);
|
StartScreen(const std::vector<std::string_view>& args, SDL_Renderer* renderer, Theme& theme);
|
||||||
~StartScreen(void) = default;
|
~StartScreen(void) = default;
|
||||||
|
@ -55,7 +55,7 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
|
|||||||
profile_data.data(),
|
profile_data.data(),
|
||||||
nullptr // TODO: error checking
|
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);
|
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_options_set_experimental_groups_persistence(options, true);
|
||||||
|
|
||||||
TOX_ERR_NEW err_new;
|
Tox_Err_New err_new;
|
||||||
_tox = tox_new(options, &err_new);
|
_tox = tox_new(options, &err_new);
|
||||||
tox_options_free(options);
|
tox_options_free(options);
|
||||||
if (err_new != TOX_ERR_NEW_OK) {
|
if (err_new != TOX_ERR_NEW_OK) {
|
||||||
std::cerr << "tox_new failed with error code " << err_new << "\n";
|
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
|
// no callbacks, use events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user