@@ -25,6 +25,7 @@ import (
25
25
"github.com/devtron-labs/git-sensor/internals/sql"
26
26
"github.com/devtron-labs/git-sensor/internals/util"
27
27
"github.com/devtron-labs/git-sensor/pkg/git"
28
+ util2 "github.com/devtron-labs/git-sensor/util"
28
29
_ "github.com/robfig/cron/v3"
29
30
"go.uber.org/zap"
30
31
"strings"
@@ -209,11 +210,7 @@ func (impl RepoManagerImpl) updatePipelineMaterialCommit(gitCtx git.GitContext,
209
210
return gitCtx .Err ()
210
211
} else if err != nil {
211
212
pipelineMaterial .Errored = true
212
- if errMsg != "" {
213
- pipelineMaterial .ErrorMsg = errMsg
214
- } else {
215
- pipelineMaterial .ErrorMsg = err .Error ()
216
- }
213
+ pipelineMaterial .ErrorMsg = util2 .BuildDisplayErrorMessage (errMsg , err )
217
214
pipelineMaterial .LastSeenHash = ""
218
215
} else {
219
216
impl .logger .Infow ("commits found" , "commit" , commits )
@@ -377,11 +374,7 @@ func (impl RepoManagerImpl) checkoutMaterial(gitCtx git.GitContext, material *sq
377
374
} else if err != nil {
378
375
material .CheckoutStatus = false
379
376
material .CheckoutMsgAny = err .Error ()
380
- if errMsg != "" {
381
- material .FetchErrorMessage = errMsg
382
- } else {
383
- material .FetchErrorMessage = err .Error ()
384
- }
377
+ material .FetchErrorMessage = util2 .BuildDisplayErrorMessage (errMsg , err )
385
378
} else {
386
379
material .CheckoutLocation = checkoutLocationForFetching
387
380
material .CheckoutStatus = true
@@ -683,11 +676,7 @@ func (impl RepoManagerImpl) GetLatestCommitForBranch(gitCtx git.GitContext, pipe
683
676
if err != nil {
684
677
gitMaterial .CheckoutStatus = false
685
678
gitMaterial .CheckoutMsgAny = err .Error ()
686
- if errMsg != "" {
687
- gitMaterial .FetchErrorMessage = errMsg
688
- } else {
689
- gitMaterial .FetchErrorMessage = err .Error ()
690
- }
679
+ gitMaterial .FetchErrorMessage = util2 .BuildDisplayErrorMessage (errMsg , err )
691
680
692
681
impl .logger .Errorw ("error in fetching the repository " , "gitMaterial" , gitMaterial , "err" , err )
693
682
return nil , err
0 commit comments