Thanks for responding. I can see the reasoning. Just seems weird that the behavior isn't documented, and that there's no way for me to override it. I'll file a bug for updating the Javadoc.
On Friday, January 25, 2013 2:40:10 PM UTC-8, Robert Greenwalt wrote: > > You can always do the dns lookup yourself and log an error if it's > invalid. The DNS cache will ensure it's not wasted effort. > > > On Fri, Jan 25, 2013 at 2:39 PM, Robert Greenwalt > <[email protected]<javascript:> > > wrote: > >> I think the log was getting quite full of these exceptions (mobile >> devices often don't have a network and apps aren't so good at checking that >> first) so we stopped logging them. If you look at the blame for this code >> you can see the reasoning. >> >> >> >> On Fri, Jan 25, 2013 at 2:31 PM, Boris Burtin <[email protected]<javascript:> >> > wrote: >> >>> I was racking my brain, trying to figure out why one of my users was >>> having trouble connecting and nothing was in the logs. Finally I looked at >>> the Android source and realized that the logging code explicitly ignores >>> UnknownHostException. Even worse, the Javadoc doesn't specify this >>> behavior. >>> >>> Does this sound like a bug to anyone, as opposed to a feature? In my >>> case, the user enters the hostname, so it's possible to get this exception >>> while the user has a network connection. >>> >>> /** >>> * Handy function to get a loggable stack trace from a Throwable >>> * @param tr An exception to log >>> */ >>> public static String getStackTraceString(Throwable tr) { >>> if (tr == null) { >>> return ""; >>> } >>> >>> // This is to reduce the amount of log spew that apps do in the >>> non-error >>> // condition of the network being unavailable. >>> Throwable t = tr; >>> while (t != null) { >>> if (t instanceof UnknownHostException) { >>> return ""; >>> } >>> t = t.getCause(); >>> } >>> >>> StringWriter sw = new StringWriter(); >>> PrintWriter pw = new PrintWriter(sw); >>> tr.printStackTrace(pw); >>> return sw.toString(); >>> } >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to >>> [email protected]<javascript:> >>> To unsubscribe from this group, send email to >>> [email protected] <javascript:> >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >>> >>> >> >> > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" 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/android-developers?hl=en

