Merged in bugfix/errhandling (pull request #89)

Error handling

* basic
This commit is contained in:
Michael McGuinness
2025-03-05 19:49:03 +00:00
parent c78ca26a6f
commit 8f409e60a8
36 changed files with 965 additions and 641 deletions
+9 -5
View File
@@ -3,6 +3,7 @@ package doctextrunner
import (
"context"
"encoding/json"
"log/slog"
documenttext "queryorchestration/internal/document/text"
@@ -34,22 +35,25 @@ type Body struct {
ID uuid.UUID `json:"id" validate:"required,uuid"`
}
func (s Runner) Process(ctx context.Context, req *types.Message) error {
func (s Runner) Process(ctx context.Context, req *types.Message) bool {
var body Body
err := json.Unmarshal([]byte(*req.Body), &body)
if err != nil {
return err
slog.Error("parsing body", "messageId", *req.MessageId, "body", *req.Body)
return true
}
err = s.validator.Struct(body)
if err != nil {
return err
slog.Error("invalid body", "messageId", *req.MessageId, "error", err)
return true
}
err = s.svc.Text.Extract(ctx, body.ID)
if err != nil {
return err
slog.Error("unable to process", "error", err)
return false
}
return nil
return true
}