Many exceptions do not have a message, e.g. NullPointerException
(unless thrown by hand).
Maybe:
try {
...
} catch {
case ex: Exception if ex.getMessage == null => "Message: " +
ex.toString
case ex: Exception => "Message: " + ex.getMessage
}
-Ross
On Nov 5, 2009, at 11:45 PM, jack wrote:
>
> I'm using the Dispatch Databinder library for Http. http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
> try {
> var http = new Http
> var request = new Request
> (url)
> val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
> val responseBody = Http (req_with_agent as_str)
> responseBody.length.toString
> } catch {
> case ex: Exception => {
> "Message: " + ex.getMessage
> }
> }
> }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---