Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

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: Changed 17 years ago by jmoore

Can I suggest:

void Log.error(java.lang.Object message, java.lang.Throwable t) 

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.");
}
Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.65529 sec.)

We're Hiring!