Task #730 (closed)
Opened 17 years ago
Closed 17 years ago
Removal of e.printStackTrace() from the codebase
Reported by: | cxallan | Owned by: | dwhitehurst-x |
---|---|---|---|
Priority: | minor | Milestone: | n.a. |
Component: | General | Version: | n.a. |
Keywords: | n.a. | Cc: | jamoore |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | n.a. |
Sprint: | n.a. |
Description
There should be no locations where e.printStackTrace() is used as it only drops debugging information on the console.
For example:
try { compressThumbnailToDisk(metadata, image); } catch (IOException e) { e.printStackTrace(); throw new ResourceError(e.getMessage()); }
should be...
try { compressThumbnailToDisk(metadata, image); } catch (IOException e) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); log.error(result.toString()); throw new ResourceError(e.getMessage() + " Please check server log."); }
If needed, the logger should be created in the class as follows:
/** The logger for this class. */ private static Log log = LogFactory.getLog(ThumbnailBean.class);
Change History (5)
comment:1 Changed 17 years ago by cxallan
- Type changed from User Story to Task
- Version 3.0-M1 deleted
comment:2 follow-up: ↓ 3 Changed 17 years ago by jmoore
comment:3 in reply to: ↑ 2 Changed 17 years ago by cxallan
Replying to jmoore:
Can I suggest:
void Log.error(java.lang.Object message, java.lang.Throwable t)
Looks perfect.
comment:4 Changed 17 years ago by cxallan
Okay, so to use Josh's spiffy Log method:
try { compressThumbnailToDisk(metadata, image); } catch (IOException e) { e.printStackTrace(); throw new ResourceError(e.getMessage()); }
should be...
try { compressThumbnailToDisk(metadata, image); } catch (IOException e) { log.error("Failure compressing thumbnail", e); throw new ResourceError(e.getMessage() + " Please check server log."); }
comment:5 Changed 17 years ago by dwhitehurst-x
- Resolution set to fixed
- Status changed from new to closed
Was handled like so ...
try { compressThumbnailToDisk(metadata, image); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug("Failure compressing thumbnail", e); } throw new ResourceError(e.getMessage() + " Please check server log."); }
Can I suggest: