Skip to content

Commit

Permalink
refactor(coordinator): remove error details to prover and add error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Aug 23, 2023
1 parent 574aa68 commit 9113128
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions coordinator/internal/controller/api/get_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
"github.com/scroll-tech/go-ethereum/log"
"gorm.io/gorm"

"scroll-tech/common/types"
Expand Down Expand Up @@ -55,8 +56,8 @@ func (ptc *GetTaskController) GetTasks(ctx *gin.Context) {

result, err := proverTask.Assign(ctx, &getTaskParameter)
if err != nil {
nerr := fmt.Errorf("return prover task err:%w", err)
coordinatorType.RenderJSON(ctx, types.ErrCoordinatorGetTaskFailure, nerr, nil)
log.Error("assign prover task failed", "err", err)
coordinatorType.RenderJSON(ctx, types.ErrCoordinatorGetTaskFailure, nil, nil)
return
}

Expand Down
8 changes: 7 additions & 1 deletion coordinator/internal/types/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"net/http"

"github.com/gin-gonic/gin"

"scroll-tech/common/types"
)

// Response the response schema
Expand All @@ -17,7 +19,11 @@ type Response struct {
func RenderJSON(ctx *gin.Context, errCode int, err error, data interface{}) {
var errMsg string
if err != nil {
errMsg = err.Error()
if errCode == types.ErrCoordinatorGetTaskFailure {
errMsg = "Internal Server Error"
} else {
errMsg = err.Error()
}
}
renderData := Response{
ErrCode: errCode,
Expand Down

0 comments on commit 9113128

Please sign in to comment.