Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ var ErrNotFoundAnswer = errors.New("not found answer")

type QuestionExceptionRepeated struct {
RepeatedQuestionCount int
Question string
Answer string
}

func (e *QuestionExceptionRepeated) Error() string {
return fmt.Sprintf("repeated question count=%d", e.RepeatedQuestionCount)
return fmt.Sprintf("break loop of repeated questions: q=%q, a=%q, count=%d", e.Question, e.Answer, e.RepeatedQuestionCount)
}

func ThrowQuestionExceptionRepeated(repeatedQuestionCount int) error {
func ThrowQuestionExceptionRepeated(repeatedQuestionCount int, question, answer string) error {
return &QuestionExceptionRepeated{RepeatedQuestionCount: repeatedQuestionCount}
}

Expand Down Expand Up @@ -165,7 +167,7 @@ func (m CmdImpl) QuestionHandler(question []byte, attempt int) ([]byte, error) {
continue
}
if attempt > cmdAnswer.maxAttempts {
return nil, ThrowQuestionExceptionRepeated(attempt)
return nil, ThrowQuestionExceptionRepeated(attempt, string(question), string(ans))
}
if !cmdAnswer.notSendNL {
ans = append(ans, []byte("\n")...)
Expand Down
Loading