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

Harden message_callback against runtime error #884

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,10 +1263,15 @@ void ChargePointImpl::message_callback(const std::string& message) {
EVLOG_error << "Exception during handling of message: " << e.what();
this->message_dispatcher->dispatch_call_error(
CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({})));
return;
} catch (const json::exception& e) {
EVLOG_error << "JSON exception during reception of message: " << e.what();
this->message_dispatcher->dispatch_call_error(CallError(MessageId("-1"), "GenericError", e.what(), json({})));
return;
} catch (const std::runtime_error& e) {
EVLOG_error << "runtime_error during reception of message: " << e.what();
this->message_dispatcher->dispatch_call_error(CallError(MessageId("-1"), "GenericError", e.what(), json({})));
return;
}

auto json_message = enhanced_message.message;
Expand Down
Loading