From 9b1a175cd2192b64b770e0b0e8796b704c014d4d Mon Sep 17 00:00:00 2001 From: LinkinStar Date: Wed, 28 Sep 2022 13:29:24 +0800 Subject: [PATCH] fix: question not found return bad request --- internal/service/question_common/question.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go index 07ce1998..80da1c6b 100644 --- a/internal/service/question_common/question.go +++ b/internal/service/question_common/question.go @@ -3,12 +3,13 @@ package questioncommon import ( "context" "encoding/json" - "fmt" "time" + "github.com/segmentfault/answer/internal/base/reason" "github.com/segmentfault/answer/internal/service/activity_common" "github.com/segmentfault/answer/internal/service/config" "github.com/segmentfault/answer/internal/service/meta" + "github.com/segmentfault/pacman/errors" "github.com/segmentfault/answer/internal/entity" "github.com/segmentfault/answer/internal/schema" @@ -139,7 +140,7 @@ func (qs *QuestionCommon) Info(ctx context.Context, questionId string, loginUser return showinfo, err } if !has { - return showinfo, fmt.Errorf("the question could not be found") + return showinfo, errors.BadRequest(reason.QuestionNotFound) } showinfo = qs.ShowFormat(ctx, dbinfo)