update error handling in tcp call hander
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 29s
Build and Publish / BuildAndDeploy (push) Successful in 2m33s

This commit is contained in:
matst80
2024-11-21 21:43:14 +01:00
parent 1f7f161e62
commit d5efb39872
3 changed files with 5 additions and 4 deletions

View File

@@ -174,7 +174,7 @@ func (l *GenericListener) HandleConnection(conn net.Conn) {
case frame := <-ch:
err := l.HandleFrame(conn, &frame)
if err != nil {
log.Fatalf("Error handling frame: %v\n", err)
log.Fatalf("Error in handler: %v\n", err)
}
case <-time.After(MaxCallDuration):
close(ch)
@@ -194,7 +194,8 @@ func (l *GenericListener) HandleFrame(conn net.Conn, frame *FrameWithPayload) er
defer close(resultChan)
err := handler(frame, resultChan)
if err != nil {
log.Fatalf("Error handling frame: %v\n", err)
resultChan <- MakeFrameWithPayload(frame.Type, 500, []byte(err.Error()))
log.Printf("Handler returned error: %s", err)
}
result := <-resultChan
err = SendFrame(conn, &result)