Skip to content

Commit

Permalink
Harden message_callback against runtime error (#884)
Browse files Browse the repository at this point in the history
* Harden message_callback against runtime error

---------

Signed-off-by: Matthias Suess <[email protected]>
  • Loading branch information
Matthias-NIDEC authored Dec 4, 2024
1 parent 03cc868 commit 254dfbb
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit 254dfbb

Please sign in to comment.