@@ -73,15 +73,9 @@ func (g *Github) GetCommit(ctx context.Context, u *ent.User, r *ent.Repo, sha st
7373 GetCommit (ctx , r .Namespace , r .Name , sha )
7474 // Github returns Unprocessable entity if the commit is not found.
7575 if res .StatusCode == http .StatusNotFound || res .StatusCode == http .StatusUnprocessableEntity {
76- return nil , e .NewError (
77- e .ErrorCodeRefNotFound ,
78- err ,
79- )
76+ return nil , e .NewErrorWithMessage (e .ErrorCodeNotFound , "The commit is not found." , err )
8077 } else if err != nil {
81- return nil , e .NewError (
82- e .ErrorCodeInternalError ,
83- err ,
84- )
78+ return nil , e .NewError (e .ErrorCodeInternalError , err )
8579 }
8680
8781 return mapGithubCommitToCommit (cm ), nil
@@ -97,10 +91,7 @@ func (g *Github) ListCommitStatuses(ctx context.Context, u *ent.User, r *ent.Rep
9791 PerPage : 100 ,
9892 })
9993 if err != nil {
100- return nil , e .NewError (
101- e .ErrorCodeInternalError ,
102- err ,
103- )
94+ return nil , err
10495 }
10596
10697 for _ , rs := range cs .Statuses {
@@ -115,10 +106,7 @@ func (g *Github) ListCommitStatuses(ctx context.Context, u *ent.User, r *ent.Rep
115106 })
116107 // check-runs secures the commit is exist.
117108 if res .StatusCode == http .StatusUnprocessableEntity {
118- return nil , e .NewError (
119- e .ErrorCodeRefNotFound ,
120- err ,
121- )
109+ return nil , e .NewErrorWithMessage (e .ErrorCodeNotFound , "The commit is not found." , err )
122110 } else if err != nil {
123111 return nil , e .NewError (
124112 e .ErrorCodeInternalError ,
@@ -143,10 +131,7 @@ func (g *Github) ListBranches(ctx context.Context, u *ent.User, r *ent.Repo, pag
143131 },
144132 })
145133 if err != nil {
146- return nil , e .NewError (
147- e .ErrorCodeInternalError ,
148- err ,
149- )
134+ return nil , e .NewError (e .ErrorCodeInternalError , err )
150135 }
151136
152137 branches := []* vo.Branch {}
@@ -162,15 +147,9 @@ func (g *Github) GetBranch(ctx context.Context, u *ent.User, r *ent.Repo, branch
162147 Repositories .
163148 GetBranch (ctx , r .Namespace , r .Name , branch )
164149 if res .StatusCode == http .StatusNotFound {
165- return nil , e .NewError (
166- e .ErrorCodeRefNotFound ,
167- err ,
168- )
150+ return nil , e .NewErrorWithMessage (e .ErrorCodeNotFound , "The branch is not found." , err )
169151 } else if err != nil {
170- return nil , e .NewError (
171- e .ErrorCodeInternalError ,
172- err ,
173- )
152+ return nil , e .NewError (e .ErrorCodeInternalError , err )
174153 }
175154
176155 return mapGithubBranchToBranch (b ), nil
@@ -249,10 +228,7 @@ func (g *Github) GetTag(ctx context.Context, u *ent.User, r *ent.Repo, tag strin
249228 }
250229
251230 if q .Repository .Refs .TotalCount == 0 {
252- return nil , e .NewError (
253- e .ErrorCodeRefNotFound ,
254- nil ,
255- )
231+ return nil , e .NewErrorWithMessage (e .ErrorCodeNotFound , "The tag is not found." , nil )
256232 }
257233
258234 n := q .Repository .Refs .Nodes [0 ]
@@ -278,7 +254,7 @@ func (g *Github) CreateWebhook(ctx context.Context, u *ent.User, r *ent.Repo, c
278254 Active : github .Bool (true ),
279255 })
280256 if err != nil {
281- return - 1 , err
257+ return - 1 , e . NewErrorWithMessage ( e . ErrorCodeInternalError , "It has failed to create a webhook." , err )
282258 }
283259
284260 return * h .ID , nil
0 commit comments