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

exit without error message #3948

Closed
1 of 2 tasks
tesla-cat opened this issue Feb 20, 2023 · 5 comments
Closed
1 of 2 tasks

exit without error message #3948

tesla-cat opened this issue Feb 20, 2023 · 5 comments
Labels
kind: bug state: needs more info the author of the issue needs to provide more details

Comments

@tesla-cat
Copy link

Description

  • without the try-catch block the code works
  • but after adding that try-catch block, and after sending json data to the websocket server, the program exits without error message
void handle_message(uWS::WebSocket<false, true, PerSocketData>* ws,
                    string_view msg, uWS::OpCode code) {
    json data = json::parse(msg);

     try {
        OptimizerInput inp = data.get<OptimizerInput>();
    } catch (const exception& e) {
        cerr << e.what() << '\n';
    }

    ws->send(data.dump(), code);
}

Reproduction steps

  • the websocket server can run
  • aftering sending json data to it from the frontend, the server exits without an error message.
  • everything works without the try-catch part of the code

Expected vs. actual results

expect to see error message

Minimal code example

No response

Error messages

No response

Compiler and operating system

windows, Visual Studio 16

Library version

nlohmann_json/3.11.2

Validation

@nlohmann
Copy link
Owner

Without knowing what any of the called functions do, there is little I can do. Can you provide a stacktrace?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Feb 20, 2023
@tesla-cat
Copy link
Author

  • thanks for the quick reply
  • i added this line std::cout << boost::stacktrace::stacktrace();, but it still just exits without printing any error message
void handle_message(uWS::WebSocket<false, true, PerSocketData>* ws,
                    string_view msg, uWS::OpCode code) {
    json data = json::parse(msg);

    try {
        OptimizerInput inp = data.get<OptimizerInput>();
    } catch (const exception& e) {
        cerr << e.what() << '\n';
        std::cout << boost::stacktrace::stacktrace();
    }

    ws->send(data.dump(), code);
}

@nlohmann
Copy link
Owner

Can you set a breakpoint to the line where you call parse and find the last line before the exit?

(This looks like an issue in your setup - the library throws exceptions inherited from std::exception, and so far we never saw an issue.

@tesla-cat
Copy link
Author

the exit is caused by OptimizerInput inp = data.get<OptimizerInput>(); because everything works after removing it

@nlohmann
Copy link
Owner

Can you then debug into it? get does not throw too many exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

2 participants