@@ -304,7 +304,7 @@ func ViewPost(ctx *context_module.Context) {
304304 if task != nil {
305305 steps , logs , err := convertToViewModel (ctx , req .LogCursors , task )
306306 if err != nil {
307- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
307+ ctx .ServerError ( "convertToViewModel" , err )
308308 return
309309 }
310310 resp .State .CurrentJob .Steps = append (resp .State .CurrentJob .Steps , steps ... )
@@ -408,7 +408,7 @@ func Rerun(ctx *context_module.Context) {
408408
409409 run , err := actions_model .GetRunByIndex (ctx , ctx .Repo .Repository .ID , runIndex )
410410 if err != nil {
411- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
411+ ctx .ServerError ( "GetRunByIndex" , err )
412412 return
413413 }
414414
@@ -426,7 +426,7 @@ func Rerun(ctx *context_module.Context) {
426426 run .Started = 0
427427 run .Stopped = 0
428428 if err := actions_model .UpdateRun (ctx , run , "started" , "stopped" , "previous_duration" ); err != nil {
429- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
429+ ctx .ServerError ( "UpdateRun" , err )
430430 return
431431 }
432432 }
@@ -441,7 +441,7 @@ func Rerun(ctx *context_module.Context) {
441441 // if the job has needs, it should be set to "blocked" status to wait for other jobs
442442 shouldBlock := len (j .Needs ) > 0
443443 if err := rerunJob (ctx , j , shouldBlock ); err != nil {
444- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
444+ ctx .ServerError ( "RerunJob" , err )
445445 return
446446 }
447447 }
@@ -455,7 +455,7 @@ func Rerun(ctx *context_module.Context) {
455455 // jobs other than the specified one should be set to "blocked" status
456456 shouldBlock := j .JobID != job .JobID
457457 if err := rerunJob (ctx , j , shouldBlock ); err != nil {
458- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
458+ ctx .ServerError ( "RerunJob" , err )
459459 return
460460 }
461461 }
@@ -552,7 +552,7 @@ func Cancel(ctx *context_module.Context) {
552552 }
553553 return nil
554554 }); err != nil {
555- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
555+ ctx .ServerError ( "StopTask" , err )
556556 return
557557 }
558558
@@ -567,7 +567,7 @@ func Cancel(ctx *context_module.Context) {
567567 // Sync run status with db
568568 job .Run = nil
569569 if err := job .LoadAttributes (ctx ); err != nil {
570- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
570+ ctx .ServerError ( "LoadAttributes" , err )
571571 return
572572 }
573573 notify_service .WorkflowRunStatusUpdate (ctx , job .Run .Repo , job .Run .TriggerUser , job .Run )
@@ -607,7 +607,7 @@ func Approve(ctx *context_module.Context) {
607607 }
608608 return nil
609609 }); err != nil {
610- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
610+ ctx .ServerError ( "UpdateRunJob" , err )
611611 return
612612 }
613613
@@ -702,7 +702,7 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
702702 return
703703 }
704704 if err = actions_model .SetArtifactNeedDelete (ctx , run .ID , artifactName ); err != nil {
705- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
705+ ctx .ServerError ( "SetArtifactNeedDelete" , err )
706706 return
707707 }
708708 ctx .JSON (http .StatusOK , struct {}{})
@@ -718,7 +718,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
718718 ctx .HTTPError (http .StatusNotFound , err .Error ())
719719 return
720720 }
721- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
721+ ctx .ServerError ( "GetRunByIndex" , err )
722722 return
723723 }
724724
@@ -727,7 +727,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
727727 ArtifactName : artifactName ,
728728 })
729729 if err != nil {
730- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
730+ ctx .ServerError ( "FindArtifacts" , err )
731731 return
732732 }
733733 if len (artifacts ) == 0 {
@@ -748,7 +748,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
748748 if len (artifacts ) == 1 && actions .IsArtifactV4 (artifacts [0 ]) {
749749 err := actions .DownloadArtifactV4 (ctx .Base , artifacts [0 ])
750750 if err != nil {
751- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
751+ ctx .ServerError ( "DownloadArtifactV4" , err )
752752 return
753753 }
754754 return
@@ -761,15 +761,15 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
761761 for _ , art := range artifacts {
762762 f , err := storage .ActionsArtifacts .Open (art .StoragePath )
763763 if err != nil {
764- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
764+ ctx .ServerError ( "ActionsArtifacts.Open" , err )
765765 return
766766 }
767767
768768 var r io.ReadCloser
769769 if art .ContentEncoding == "gzip" {
770770 r , err = gzip .NewReader (f )
771771 if err != nil {
772- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
772+ ctx .ServerError ( "gzip.NewReader" , err )
773773 return
774774 }
775775 } else {
@@ -779,11 +779,11 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
779779
780780 w , err := writer .Create (art .ArtifactPath )
781781 if err != nil {
782- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
782+ ctx .ServerError ( "writer.Create" , err )
783783 return
784784 }
785785 if _ , err := io .Copy (w , r ); err != nil {
786- ctx .HTTPError ( http . StatusInternalServerError , err . Error () )
786+ ctx .ServerError ( "io.Copy" , err )
787787 return
788788 }
789789 }
0 commit comments