Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ApiErrorLogger.instance #266

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Simplify ApiErrorLogger.instance #266

merged 1 commit into from
Feb 16, 2024

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
2 checks passed
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