Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
exception
import net.liftweb.common.{Box, Empty, Failure, Full}
import net.liftweb.util.Helpers.tryo
//val option: Option[Null] = Option(null)
val box1 = Full(null)
val box2 = Full("")
val box3 = Empty
val box4 = None
val box5 = Failure("hongwei")
box3.isEmpty
val option1: Option[Null] = Option(null)
val option2 = Empty
option1.isEmpty
option2.isEmpty
val full = Full {new RuntimeException("123")}
full.get
//1/0
1 Empty--> error message
isgoodtest <- Empty ?~ ErrorMessages.InvalidJsonFormat ---> Failture(OBP-10001: Incorrect json format.") ----> "error": "OBP-10001: Incorrect json format."
the same as:
isgoodtest <- Failure(ErrorMessages.InvalidJsonFormat) ---> Failture(OBP-10001: Incorrect json format.") ----> "error": "OBP-10001: Incorrect json format."
2 Empty --> correct
isgoodtest <- tryo{Empty} ?~ ErrorMessages.InvalidJsonFormat ----> correct
same as :
isgoodtest <- Full(Empty) ?~ ErrorMessages.InvalidJsonFormat ----> correct
3 Exception ->error message
isgoodtest <- tryo {1/0} ?~ ErrorMessages.InvalidJsonFormat ---> Failture(OBP-10001: Incorrect json format.") ----> "error": "OBP-10001: Incorrect json format."
4 Exception -->Exception
isgoodtest <- Full(1/0) ?~ ErrorMessages.InvalidJsonFormat ---> Exception, not clear message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment