fix: Refactor error handling by introducing errorString function to check for nil errors
This commit is contained in:
parent
2707806a08
commit
cc2b0374da
@ -130,10 +130,11 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
|
||||
ScrapeTaskID: models.ScrapeTaskID(id),
|
||||
UserSourceID: userSource.ID,
|
||||
FinishedAt: time.Now(),
|
||||
Error: err.Error(),
|
||||
Error: errorString(err),
|
||||
AddedPosts: taskSummery.AddedPosts,
|
||||
DeletedPosts: taskSummery.DeletedPosts,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.WithContext(taskCtx).WithError(err).WithField("task_id", id).Error("Task execution failed")
|
||||
span.RecordError(err)
|
||||
@ -293,3 +294,10 @@ func (s *server) removeTask(taskID string) {
|
||||
fn()
|
||||
delete(s.ctx, taskID)
|
||||
}
|
||||
|
||||
func errorString(err error) string {
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user