[infinispan-dev] use %s syntax for formatting exception messages

David M. Lloyd david.lloyd at redhat.com
Tue Mar 15 13:20:12 EDT 2011


If you use the JBoss standard i18n library, you can put things like this 
on your message bundle interface:

    @Message("You're not allowed to use %s and %s together")
    ConfigurationException cantUseTogether(String that, String other);

then you can just do:

    throw cantUseTogether(that, other);

with the advantage that it can be translated into other languages.

On 03/15/2011 12:13 PM, Manik Surtani wrote:
> Yeah, I currently do:
>
> 	throw new ConfigurationException(String.format("you 're not allowed to use %s and %s together", that, other));
>
> but we could overload the constructor of CacheException ...
>
> On 15 Mar 2011, at 16:15, Mircea Markus wrote:
>
>> Hi,
>>
>> Not a biggie, but I think it would be nice to use this nicer syntax for exception messages, e.g.
>> throw new ConfigurationException("you 're not allowed to use %s and %s together", that, other);
>> wdyt?
>>
>> Cheers,
>> Mircea
>>
>> _______________________________________________
>> infinispan-dev mailing list
>> infinispan-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
> --
> Manik Surtani
> manik at jboss.org
> twitter.com/maniksurtani
>
> Lead, Infinispan
> http://www.infinispan.org
>
>
>
>
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev


-- 
- DML


More information about the infinispan-dev mailing list