reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anupam <anupam...@gmail.com>
Subject Re: [DISCUSS] Deprecate Exceptions.Throw?
Date Fri, 27 May 2016 02:28:54 GMT
+1 with bold and underline. :)


Before doing this, I would like us to do two things if it is not already done:

Setup UnhandledExceptionEventHandler to log in case of crash due to
unhandledexception.
Something like:
AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(delegate(object sender,
UnhandledExceptionEventArgs args)
                 {
                     if (args.IsTerminating)
                     {
                         string s =
String.Format(CultureInfo.InvariantCulture, "An unhandled exception is
about to terminate the process.  Exception info:\n{0}",
args.ExceptionObject.ToString());
                         Debug.Assert(false, s);
                     }
                 });


Secondly,
Setup UnobservedTaskException listener
Something like:

TaskScheduler.UnobservedTaskException += (sender, excArgs) =>
            {
                Trace.LogError(
                    "UnobservedTaskException",
                    string.Format("Exception={0}", excArgs.Exception));
                excArgs.SetObserved();
            };

I would like us to over time scrub the unobservedtaskexception logs
and reach a point where Trace.LogError can be converted to Trace.Fail.

Thanks!


On 26 May 2016 at 17:56, Dhruv Mahajan <dhruv.mahajan@gmail.com> wrote:
> +1 on this. This also happens when I check variables for null and then use
> "Exceptions". Resharper thinks that I have not done anything regarding
> variable being null and keeps on giving me warnings when I later access
> this variable.
>
> Dhruv
>
> On Thu, May 26, 2016 at 4:09 PM, Markus Weimer <markus@weimo.de> wrote:
>
>> Hi,
>>
>> `Exceptions.Throw()` is used in some of our C# code instead of a simple
>> `throw` call. This confuses the compiler, as it doesn't know we throw an
>> exception. We frequently have code like this:
>>
>> ```
>>   Exceptions.Throw(new ...);
>>   return null;
>> ```
>>
>> The `return null` is only needed because the compiler can't know that the
>> control flow ended in the line before. I find this very confusing.
>>
>> Hence, I'd like to deprecate the whole `Exceptions` class. What features
>> would we loose if we did?
>>
>> Markus
>>



-- 
Anupam
Bellevue, WA
Ph: +1 (425)-777-5570

Mime
View raw message