Look at this code snippet:
userService.insert(user) match {
case Success(f) => Logger.debug("User created successfully")
case Failure(e) => {
// how do I determine the type of `e`?
}
}
How do I determine the type of the exception contained by Failure
? I need to take different actions depending on the exception type.
case Success(f) =>
case Failure(e: ExceptionType1) =>
case Failure(e: ExceptionType2) =>
case Failure(e) => // other
or
case Success(f) =>
case Failure(e) => e match {
case e1: ExceptionType1 =>
case e2: ExceptioNType2 =>
case _ =>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With