Skip to content

Instantly share code, notes, and snippets.

@rupeshtr78
Last active November 4, 2020 01:34
Show Gist options
  • Save rupeshtr78/50c8e5731b9cced2a8ff43f09bb1a97e to your computer and use it in GitHub Desktop.
Save rupeshtr78/50c8e5731b9cced2a8ff43f09bb1a97e to your computer and use it in GitHub Desktop.
def catchBlocksPatternMatching(exception: Exception): String = {
try {
throw exception
} catch {
case ex: IllegalArgumentException => "It's an IllegalArgumentException"
case ex: RuntimeException => "It's a RuntimeException"
case _ => "It's an unknown kind of exception"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment