Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: streaming problem and thread freeze Date: Tue, 10 May 2011 04:47:56 -0700 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <005a9e79-36fe-4bf1-aa1d-bda3a5aaebf2@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 10 May 2011 11:48:00 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="FaSG3tOezrXhBMTb3srAdg"; logging-data="1889"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/87i0BAAcdnRpHPll9xStJtwQ7CaHymvw=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:3vIgsC8noLmizXMJSYdBwxdrcGE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3909 On 5/9/2011 8:31 PM, Lawrence D'Oliveiro wrote: > In message, Daniele Futtorovic wrote: > >> Secondly, although it is only a minor thing and only my personal >> opinion, this: >> >> } catch (IOException ex) { >> log.severe(ex.getMessage()); >> } >> >> is a *very* bad idea. Log the full stack. > > It would be so much easier if you could simply not bother to catch the > exception at all, and let your program crash with a full stack trace. Partially correct. If it's a small example program, or if it's only going to be used by developers or other folks who could make use of a stack trace, then sure, just throwing the error often works. Many times however that does not work, and then you have to catch the error, log it, and then possibly rethrow with a different exception that some higher level code is able to catch. Or you can skip logging it here, if you re-throw and you know the higher level code will log it. It takes about 20% art and about 80% prior-planning, but it's not hard to work out ways to handle errors and logging in any give subsystem. For end users, the best way imo is to have main catch all errors, then log and attempt to upload it to a central site. This avoids having to ask the users to dig through logs, up load them, or interpret them. It's just easier on everybody, yourself included.