Created
May 4, 2012 12:16
-
-
Save delitescere/2594472 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val defaultBrowserVersion = Play.configuration.getString("snapshot.browserVersion") | |
.map(extractVersion _) | |
.getOrElse(BrowserVersion.FIREFOX_3_6) // Firefox 3.6 makes a good default because it works on all OSes | |
// Do you really need to throw an exception? Why not log it as an error, and return None so you end up with the default above? | |
def extractVersion(browserString: String): Option[BrowserVersion] = { | |
allCatch opt { | |
Some(classOf[BrowserVersion].getField(browserString).get(null).asInstanceOf[BrowserVersion]) | |
} | |
.getOrElse { | |
Logger.error("Browser version not defined in HTMLUnit %s" format browserString) | |
None | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of course you have unit tests, don't you James?