Allow omitting Exception
suffix from exception type name
#2733
Replies: 6 comments
-
Sorry, having browser issues... did GitHub stop working in Edge? I claimed this might break existing code, but wanted to clarify that not necessarily if existing types are prioritized which I believe is what happens with attributes. However, would you expect this to be only after |
Beta Was this translation helpful? Give feedback.
-
I don't support (but also not against) this feature. But I think this is acceptable as context sensitive limit |
Beta Was this translation helpful? Give feedback.
-
@Thaina The problem is when you limit it to the context then you get inconsistencies. catch (Argument ae)
{
if (e is ArgumentNullException ane) { }
} If you limit it to the whole block, then some ArgumentException e;
try { }
catch
{
if (e is ArgumentNull) { ... } // ?
} What I remember when I was suggesting that the autocompletion list should only contain exceptions after Besides, I am not convinced that |
Beta Was this translation helpful? Give feedback.
-
I generally like this idea as the smurf-naming convention of sticking With hindsight, exceptions should not have had |
Beta Was this translation helpful? Give feedback.
-
@DavidArno I am thinking in the opposite. Just like @miloush I think it should be like that catch (Argument ae)
{
if (e is ArgumentNullException ane) { }
} It make more obvious that we allow shorthand only in specific context. Same as |
Beta Was this translation helpful? Give feedback.
-
Yes I mean this to be limited to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This could greatly improve code clarity. Like how we can write
[Required]
instead of[RequiredAttribute]
, how about working with exceptions like this:The compiler should allow omitting the
Exception
suffix inthrow
andcatch
expressions.Beta Was this translation helpful? Give feedback.
All reactions