• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Ticket
  • Next Ticket →

Ticket #730 (closed task: fixed)

Opened 15 months ago

Last modified 15 months ago

Removal of e.printStackTrace() from the codebase

Reported by: callan Owned by: dwhitehurst-x
Priority: minor Milestone:
Component: General Version:
Keywords: Cc: jmoore

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

  Changed 15 months ago by callan

  • version deleted
  • type changed from story to task

follow-up: ↓ 3   Changed 15 months ago by jmoore

Can I suggest:

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

in reply to: ↑ 2   Changed 15 months ago by callan

Replying to jmoore:

Can I suggest: {{{ #!java void Log.error(java.lang.Object message, java.lang.Throwable t) }}}

Looks perfect.

  Changed 15 months ago by callan

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.");
}

  Changed 15 months ago by dwhitehurst-x

  • status changed from new to closed
  • resolution set to fixed

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.

Download in other formats:

  • Comma-delimited Text
  • Tab-delimited Text
  • RSS Feed

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/