commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas <t...@online.de>
Subject Re: Proposal for creating a CompositeException in ExceptionUtils
Date Wed, 21 Oct 2020 21:41:41 GMT
I understand the use case.

But starting with JDK 7, java.lang.Throwable has

   Throwable#addSuppressed(Throwable)

   Throwable[] getSuppressed()

which would lend themselves pretty obviously to the purpose, at least if
the mechanism hasn't been disabled using the special ctor

protected Throwable(String message, Throwable cause,
                        boolean enableSuppression,
                        boolean writableStackTrace)

And the suppressed are printed!

So, probably, we are loading ourselves with future redundancy, aren't we?  

On 17.07.2020 20:10, Adwait Kumar Singh wrote:
> Sample use cases:
> 1. Perform multiple operations, some failed due to different reasons.
> Return a CompositeException for the failed ones.
> 2. Do a validation on some input. I want to collect all different failures,
> I can throw a CompositeException.
> 3. In some cases the exception had occurred earlier, and we want to throw
> all such exceptions. For example failures caused by Java Agent, some java
> agents store such failures. During actual execution I want to throw all
> such exceptions.
>
> Basically any such scenarios where there are multiple causes for failure
> and I want to throw all of them.
>
> On Fri, Jul 17, 2020 at 10:06 PM sebb <sebbaz@gmail.com> wrote:
>
>> What is the use case for this?
>>
>> On Fri, 17 Jul 2020 at 16:29, Adwait Kumar Singh
>> <theadvaitkumarsingh@gmail.com> wrote:
>>> Yes Gary, something similar. However it would differ from IOExceptionList
>>> which creates an aggregated message of all exceptions but loses the
>>> stacktrace via getCause or printStackTrace.
>>>
>>> To be precise, this is exactly what I am taking about
>>>
>> https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException
>> .
>>> <
>> https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java
>>>
>>> Created a JIRA issue <https://issues.apache.org/jira/browse/LANG-1590>
>> for
>>> the same.
>>>
>>> <
>> https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java
>>>
>>> On Fri, Jul 17, 2020 at 8:44 PM Gary Gregory <garydgregory@gmail.com>
>> wrote:
>>>> Would it be like Common IO's IOExceptionList or Commons DBCP
>>>> SQLExceptionList ?
>>>>
>>>> Gary
>>>>
>>>> On Fri, Jul 17, 2020 at 11:01 AM Adwait Kumar Singh <
>>>> theadvaitkumarsingh@gmail.com> wrote:
>>>>
>>>>> To be more specific, I meant a util function in ExceptionUtils. Like
>>>> this,
>>>>> ExceptionUtils.createCompositeException(String overallErrorMessage,
>>>>> Throwable... throwables)
>>>>>
>>>>> This would return a CompositeException which would contain all the
>>>>> Throwables and whose getCause() and printStackTrace() methods have
>> been
>>>>> overridden to given out a verbose cause and stacktrace which would
>> be an
>>>>> aggregation of the throwables supplied.
>>>>>
>>>>> Pardon me if this is not the correct platform or right mechanism to
>>>> propose
>>>>> such changes. Please let me know the correct way to proceed.
>>>>>
>>>>> Thanks,
>>>>> Adwait.
>>>>>
>>>>> On Fri, Jul 17, 2020 at 5:18 PM Adwait Kumar Singh <
>>>>> theadvaitkumarsingh@gmail.com> wrote:
>>>>>
>>>>>> Hi Commons devs,
>>>>>>
>>>>>> Use case : Ability to a single exceptions with multiple causes.
>> This
>>>>>> required in validation or initialization scenarios for example
>> when I
>>>>> want
>>>>>> to Validation/Initialization failures for multiple reasons and each
>>>>> reason
>>>>>> having a unique cause.
>>>>>> RxJava provides something similar
>>>>>> <
>> https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/exceptions/CompositeException.java
>>>>>> .
>>>>>>
>>>>>> Wanted to know if this makes sense, would raise a PR if it does.
>>>>>>
>>>>>> Thanks,
>>>>>> Adwait.
>>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message