From 4ed61daf8e25d106316d7f0dda40fa811a51f970 Mon Sep 17 00:00:00 2001 From: mudler Date: Tue, 16 Apr 2024 10:26:55 +0200 Subject: [PATCH] Better error handling --- example/webui/connector/githubissue.go | 32 +++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/example/webui/connector/githubissue.go b/example/webui/connector/githubissue.go index e38c210..d7e17a2 100644 --- a/example/webui/connector/githubissue.go +++ b/example/webui/connector/githubissue.go @@ -152,19 +152,25 @@ func (g *GithubIssues) issuesService() { continue } - res := g.agent.Ask( - agent.WithConversationHistory(messages), - ) + go func() { + res := g.agent.Ask( + agent.WithConversationHistory(messages), + ) + if res.Error != nil { + slog.Error("Error asking", "error", res.Error) + return + } - _, _, err := g.client.Issues.CreateComment( - g.agent.Context(), - g.owner, g.repository, - issue.GetNumber(), &github.IssueComment{ - Body: github.String(res.Response), - }, - ) - if err != nil { - slog.Info("Error creating comment", err) - } + _, _, err := g.client.Issues.CreateComment( + g.agent.Context(), + g.owner, g.repository, + issue.GetNumber(), &github.IssueComment{ + Body: github.String(res.Response), + }, + ) + if err != nil { + slog.Error("Error creating comment", "error", err) + } + }() } }