Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
}
}
@delitescere

This comment has been minimized.

Copy link
Owner Author

delitescere commented May 4, 2012

Of course you have unit tests, don't you James?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.