Created
May 28, 2015 06:06
-
-
Save pjazdzewski1990/b72bd4d08157422cf138 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
def main (args: Array[String]): Unit = { | |
def jsonString = "[1, 2, 3]" | |
def errorString = "][" | |
println("Value or Exception: ") | |
println(parseAsValueOrException(jsonString)) | |
Try{ parseAsValueOrException(errorString) }.recover { | |
case err:Throwable => println(s"Exception '$err' was thrown") | |
} | |
println("\nEither: ") | |
println(parseAsEither(jsonString)) | |
println(parseAsEither(errorString)) | |
println("\nOption: ") | |
println(parseAsOption(jsonString)) | |
println(parseAsOption(errorString)) | |
println("\nTry: ") | |
println(parseAsTry(jsonString)) | |
println(parseAsTry(errorString)) | |
println("\nFuture: ") | |
parseAsFuture(jsonString).onSuccess {case x => println(s"Future ended with '$x'"); x } | |
parseAsFuture(errorString).onFailure {case x: Throwable => println(s"Future failed with '$x'"); x } | |
println("\nJava Style: ") | |
println(parseAsJava(jsonString)) | |
println(parseAsJava(errorString)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment