Skip to content

Commit

Permalink
Merge pull request #616 from isucon/improve-error-message
Browse files Browse the repository at this point in the history
エラーメッセージを改善
  • Loading branch information
wtks authored Dec 4, 2024
2 parents d6a7bc1 + 0c0abfa commit 0e2c11e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bench/benchmarker/world/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const (
ErrorCodeUncontrollableRequestReceived
// ErrorCodeChairReceivedDataIsWrong 椅子が通知から受け取ったデータが想定と異なります
ErrorCodeChairReceivedDataIsWrong
// ErrorCodeWrongNearbyChairs 取得した付近の椅子情報に不備があります
ErrorCodeWrongNearbyChairs
)

var CriticalErrorCodes = map[ErrorCode]bool{
Expand Down Expand Up @@ -107,6 +109,7 @@ var ErrorTexts = map[ErrorCode]string{
ErrorCodeTooOldNearbyChairsResponse: "取得した付近の椅子情報が古すぎます",
ErrorCodeUncontrollableRequestReceived: "アサインされたライドがベンチマーカー外で作られたものであるため処理できません",
ErrorCodeChairReceivedDataIsWrong: "椅子が受け取った通知の内容が想定と異なります",
ErrorCodeWrongNearbyChairs: "取得した付近の椅子情報に不備があります",
}

type codeError struct {
Expand Down
4 changes: 2 additions & 2 deletions bench/benchmarker/world/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ func (u *User) CreateRequest(ctx *Context) error {
now := time.Now()
nearby, err := u.Client.GetNearbyChairs(ctx, pickup, checkDistance)
if err != nil {
return WrapCodeError(ErrorCodeFailedToCreateRequest, err)
return WrapCodeError(ErrorCodeWrongNearbyChairs, err)
}
if err := u.World.checkNearbyChairsResponse(now, pickup, checkDistance, nearby); err != nil {
return WrapCodeError(ErrorCodeFailedToCreateRequest, err)
return WrapCodeError(ErrorCodeWrongNearbyChairs, err)
}
if len(nearby.Chairs) == 0 {
// 近くに椅子が無いので配車をやめる
Expand Down
2 changes: 1 addition & 1 deletion bench/benchmarker/world/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (w *World) checkNearbyChairsResponse(baseTime time.Time, current Coordinate
}
entries := c.Location.GetPeriodsByCoord(chair.Coordinate)
if len(entries) == 0 {
return fmt.Errorf("ID:%sの椅子はレスポンスの座標に過去存在したことがありません", chair.ID)
return fmt.Errorf("ID:%sの椅子はレスポンスされた座標に過去存在したことがありません", chair.ID)
}
for _, req := range c.RequestHistory.BackwardIter() {
if req.BenchMatchedAt.After(baseTime) {
Expand Down

0 comments on commit 0e2c11e

Please sign in to comment.