Skip to content

Commit

Permalink
Log errors encountered handling responses, send InternalError
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont authored and lorenzodonini committed Jun 27, 2021
1 parent ab788f9 commit ec88e19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ocpp1.6/central_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@ func (cs *centralSystem) Start(listenPort int, listenPath string) {
func (cs *centralSystem) sendResponse(chargePointId string, confirmation ocpp.Response, err error, requestId string) {
// send error response
if err != nil {
err := cs.server.SendError(chargePointId, requestId, ocppj.ProtocolError, "Couldn't generate valid confirmation", nil)
cs.error(fmt.Errorf("error handling request: %w", err))
err := cs.server.SendError(chargePointId, requestId, ocppj.InternalError, "Error handling request", nil)
if err != nil {
err = fmt.Errorf("replying cp %s to request %s with 'protocol error': %w", chargePointId, requestId, err)
err = fmt.Errorf("error replying cp %s to request %s with 'internal error': %w", chargePointId, requestId, err)
cs.error(err)
}
return
Expand All @@ -422,7 +423,7 @@ func (cs *centralSystem) sendResponse(chargePointId string, confirmation ocpp.Re
// send confirmation response
err = cs.server.SendResponse(chargePointId, requestId, confirmation)
if err != nil {
err = fmt.Errorf("replying cp %s to request %s: %w", chargePointId, requestId, err)
err = fmt.Errorf("error replying cp %s to request %s: %w", chargePointId, requestId, err)
cs.error(err)
}
}
Expand Down

0 comments on commit ec88e19

Please sign in to comment.