Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network errors are not reported to the user #50

Open
mross-ua opened this issue Jul 8, 2024 · 1 comment
Open

Network errors are not reported to the user #50

mross-ua opened this issue Jul 8, 2024 · 1 comment
Labels
bug Something isn't working question Further information is requested

Comments

@mross-ua
Copy link
Owner

mross-ua commented Jul 8, 2024

We need to be able to detect connection issues and other network problems and report them to the user. As of now, we can detect errors coming from the API itself (see kdeck::Api::HandleResponse) but all API requests are invoked from various parts of the UI code so there's not a universal handler of other kinds of errors and we just show a generic message.

In #49, it was discovered that a particular exception type is thrown if a server cannot be authenticated (see RequestExecutor::RequestExecutionError. It is not known yet if this is the only exception type that can come from Oat++'s client framework.

@mross-ua mross-ua added the bug Something isn't working label Jul 8, 2024
@mross-ua mross-ua changed the title Network errors should be reported to the user Network errors are not reported to the user Jul 8, 2024
@mross-ua
Copy link
Owner Author

mross-ua commented Jul 8, 2024

Here's an example try-catch block:

try
{
    api.Login(dlgLogin.GetEmail(), dlgLogin.GetPassword());

    wxCommandEvent* evt = new wxCommandEvent(EVT_LOGIN);
    evt->SetEventObject(this);
    evt->SetString("Login succeeded!");
    QueueEvent(evt);
}
catch (oatpp::web::client::RequestExecutor::RequestExecutionError &e)
{
    std::cerr << e.getErrorCode() << std::endl;
    std::cerr << e.getReadErrorCode() << std::endl;
    std::cerr << e.getMessage() << std::endl;

    wxCommandEvent* evt = new wxCommandEvent(EVT_API_ERROR);
    evt->SetEventObject(this);
    evt->SetString("Unknown network error!");
    QueueEvent(evt);
}
catch (std::exception &e)
{
    wxCommandEvent* evt = new wxCommandEvent(EVT_API_ERROR);
    evt->SetEventObject(this);
    evt->SetString("Login failed!");
    QueueEvent(evt);
}

@mross-ua mross-ua added the question Further information is requested label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant