[wildfly-dev] Return types of i18n logging methods and their "equality" expectations
Jaikiran Pai
jpai at redhat.com
Sat Apr 27 23:10:58 EDT 2013
On Saturday 27 April 2013 09:11 PM, James R. Perkins wrote:
> Not that wouldn't work. Each invocation of fooBar() will return a new
> instance of SomeException.
Ok. I thought that for no param messages the return type would be cached
and reused.
>
> Why not just do
>
> try {
> doSomething();
> } catch (SomeException e) {
> // handle
> } catch (Exception e) {
> // do something else
> }
The SomeException (in this case an EJBException) gets thrown for various
other reasons and from various other parts of the code. I just want to
handle one specific case when that exception gets thrown. I can just let
the code throw a specialized exception type to handle it, but I was
curious if relying on the existing logging message infrastructure would
work, the answer to which is - it won't :)
-Jaikiran
>
> On 04/27/2013 06:17 AM, Jaikiran Pai wrote:
>> I have a interface annotated with @MessageBundle which has a method:
>>
>> @Message(id = xxxx, value = "No param message")
>> SomeException fooBar();
>>
>>
>> So the method expects no format params for the log message and returns a
>> "SomeException" type. Assuming some piece of code then uses this logging
>> method to do:
>>
>> throw fooBar();
>>
>> is it fine to expect that if the caller does:
>>
>> try {
>> ...
>> doSomething();
>> } catch (Exception e) {
>> // is this fine to do?
>> if (e.equals(fooBar()) {
>> // do some other thing
>> }
>> }
>>
>> I think the equals and even == would work for the no param logger
>> method, but is this considered as relying/guessing about the
>> implementation details or is this fine to do?
>>
>> -Jaikiran
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
More information about the wildfly-dev
mailing list