Skip to content

Commit

Permalink
Change RefreshErrorAlg such that it also works with null messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas committed Nov 1, 2021
1 parent 1d81cf8 commit 981dd86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class RefreshErrorAlg[F[_]](
def persistError[A](repo: Repo)(fa: F[A]): F[A] =
fa.handleErrorWith { t =>
dateTimeAlg.currentTimestamp.flatMap { now =>
kvStore.put(repo, Entry(now, t.getMessage))
kvStore.put(repo, Entry(now, t.toString))
} >> F.raiseError[A](t)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class RefreshErrorAlgTest extends CatsEffectSuite {
val p = refreshErrorAlg.persistError(repo)(MockEff.raiseError(new Throwable())).attempt >>
refreshErrorAlg.skipIfFailedRecently(repo)(MockEff.unit)

val expected = "Skipping due to previous error"
p.runA(MockState.empty).attempt.map { obtained =>
assert(obtained.fold(_.getMessage, _.toString).contains("Skipping due to previous error"))
val message = obtained.fold(_.getMessage, _.toString).take(expected.length)
assertEquals(message, expected)
}
}
}

0 comments on commit 981dd86

Please sign in to comment.