hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/impl MessagesImpl.java
Date Tue, 20 Jul 2004 17:25:20 GMT
hlship      2004/07/20 10:25:20

  Modified:    framework/src/java/org/apache/hivemind/impl
                        MessagesImpl.java
  Log:
  Improve how Messages outputs exceptions (to match MessageFormatter).
  
  Revision  Changes    Path
  1.6       +18 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/MessagesImpl.java
  
  Index: MessagesImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/MessagesImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MessagesImpl.java	17 Jun 2004 15:16:11 -0000	1.5
  +++ MessagesImpl.java	20 Jul 2004 17:25:20 -0000	1.6
  @@ -34,6 +34,9 @@
   /**
    * Implementation of {@link org.apache.hivemind.Messages} for
    * a {@link org.apache.hivemind.internal.Module}.
  + * 
  + * TODO: Refactor this and {@link org.apache.hivemind.impl.MessageFormatter} into
  + * common base classes.
    *
    * @author Howard Lewis Ship
    */
  @@ -127,6 +130,14 @@
       {
           String pattern = getMessage(key);
   
  +        for (int i = 0; i < args.length; i++)
  +        {
  +            Object arg = args[i];
  +
  +            if (arg != null && arg instanceof Throwable)
  +                args[i] = extractMessage((Throwable) arg);
  +        }
  +
           // This ugliness is mandated for JDK 1.3 compatibility, which has a bug 
           // in MessageFormat ... the
           // pattern is applied in the constructor, using the system default Locale,
  @@ -138,6 +149,13 @@
           messageFormat.applyPattern(pattern);
   
           return messageFormat.format(args);
  +    }
  +
  +    private String extractMessage(Throwable t)
  +    {
  +        String message = t.getMessage();
  +
  +        return HiveMind.isNonBlank(message) ? message : t.getClass().getName();
       }
   
       public String format(String key, Object arg0)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message