Skip to content

Instantly share code, notes, and snippets.

@p3t0r
Created March 14, 2011 21:41
Show Gist options
  • Save p3t0r/869944 to your computer and use it in GitHub Desktop.
Save p3t0r/869944 to your computer and use it in GitHub Desktop.
class BigFailRepository extends Repository[String] {
override def withConnection(f: (Connection => Option[String])): Option[String] = {
throw new UnsupportedOperationException("BAM")
}
}
class SmallFailRepository extends Repository[String] {
var numFails = 0
override def withConnection(f: (Connection => Option[String])): Option[String] = {
if (numFails < 2) {
numFails = numFails + 1
throw new UnsupportedOperationException("BAM")
}
f(null) // left out transaction mngnt to keep stuff simple
}
}
class NoFailRepository extends Repository[String] {
override def withConnection(f: (Connection => Option[String])): Option[String] = {
f(null) // left out transaction mngnt to keep stuff simple
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment