You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by T Master <tm...@iknowledge.com> on 2002/02/11 21:09:27 UTC

WriterAppender.createWriter - opinion of exception catching

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>