Playframework - API for checking if Http context exists
Many game APIs provide a runtime exception. "HTTP context not available." Ex. using the following code in a playtemplate can throw this exception at runtime.
flash().remove("message")
So far, to solve this problem, I use try / catch blocks and there is an exception in the case where the http context is not available, but I would rather check if the http context is available or not, instead of having an exception, it is any API that allows the user to check for the existence of a http context? I tried following but it also ended up with a runtime exception
@if(Http.Context.current() != null) {
@* Do something here which needs http context *@
}
+3
source to share