Skip to content

Commit

Permalink
Merge pull request #146 from codecrafters-io/CC-1213-clojure-caching
Browse files Browse the repository at this point in the history
CC-1213: add "CodeCrafters internal error" to anticheat error scenarios
  • Loading branch information
ryan-gang committed May 23, 2024
2 parents acd143e + 7180083 commit e2c87bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/anti_cheat.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ import (
)

func antiCheatTest(stageHarness *test_case_harness.TestCaseHarness) error {
logger := stageHarness.Logger

b := redis_executable.NewRedisExecutable(stageHarness)
if err := b.Run(); err != nil {
return err
logger.Criticalf("CodeCrafters internal error. Error instantiating executable: %v", err)
logger.Criticalf("Try again? Please contact us at hello@codecrafters.io if this persists.")
return fmt.Errorf("anti-cheat (ac1) failed")
}

logger := stageHarness.Logger

client, err := instrumented_resp_connection.NewFromAddr(stageHarness, "localhost:6379", "replica")
if err != nil {
logFriendlyError(logger, err)
return err
logger.Criticalf("CodeCrafters internal error. Error creating connection to redis server: %v", err)
logger.Criticalf("Try again? Please contact us at hello@codecrafters.io if this persists.")
return fmt.Errorf("anti-cheat (ac1) failed")
}
defer client.Close()

Expand All @@ -36,7 +40,7 @@ func antiCheatTest(stageHarness *test_case_harness.TestCaseHarness) error {

if err == nil {
logger.Criticalf("anti-cheat (ac1) failed.")
logger.Criticalf("Please contact us at hello@codecrafters.io if you think is a mistake.")
logger.Criticalf("Please contact us at hello@codecrafters.io if you think this is a mistake.")
return fmt.Errorf("anti-cheat (ac1) failed")
} else {
return nil
Expand Down

0 comments on commit e2c87bb

Please sign in to comment.