logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "T Master" <tmas...@iknowledge.com>
Subject WriterAppender.createWriter - opinion of exception catching
Date Mon, 11 Feb 2002 20:09:27 GMT

Upon catching the IOException, a warning msg is output:
    LogLog.warn("Unsupported encoding?");

Would it not be better to explicitly catch the UnsupportedEncodingException and
log the appropriate msg then?
For example:

  protected
  OutputStreamWriter createWriter(OutputStream os) {
    OutputStreamWriter retval = null;

    String enc = getEncoding();
    if(enc != null) {
      try {
 retval = new OutputStreamWriter(os, enc);
      }catch (UnsupportEncodingException uee) {
 LogLog.warn("Error initializing output writer.");
 LogLog.warn("Unsupported encoding.");

  } catch(IOException e) {
 LogLog.warn("Error initializing output writer.");
      }
    }
    if(retval == null) {
      retval = new OutputStreamWriter(os);
    }
    return retval;
  }


I am not in fact a subscriber to the dev mailing list, only the user mailing
list.
Thought I would share my thoughts though.

Regards,

T Master


--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message