Skip to content

Conversation

@Masynchin
Copy link
Contributor

Aim of this PR is to simplify ApiErrorLogger.instance by replacing ..pure[IO].ifM.. with just a whenA. Both ifM and whenA takes effect by name, so no penalty for whenA usage over ifM.

I also extracted logger calls into a separate function, so that ApiErrorLogger.instance shortens to:

def instance(using Logger[IO]): HttpApp[IO] => HttpApp[IO] = http =>
  Kleisli: req =>
    http(req).flatTap: res =>
      logError(req, res).whenA(isResponseError(res))

I hope this change simplifies the code so it is easier to maintain. Looking for CI tests, because of my inability to running tests locally

@lenguyenthanh
Copy link
Member

Thanks, this looks great! I believe this works and better than the previous version.

Unfortunately we don't have test for this. But I guess it is quite easy to add tests for this.

@lenguyenthanh lenguyenthanh merged commit 07eef60 into lichess-org:master Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants