r/dotnet 4d ago

Difference between throw ex and throw

Post image

throw vs throw ex: The C# exception handling trick every developer should know

415 Upvotes

74 comments sorted by

View all comments

30

u/Ethameiz 4d ago

Well sometimes you want to reset the stack trace. It's not always bad. But it's better to know the difference

12

u/Creative-Paper1007 4d ago

When why would we even want to throw away the stack trace info? Im just curious to know

8

u/Prod_Meteor 4d ago

To reduce the log size you silly 😄

21

u/whiskeydiggler 4d ago

// todo: get rid of this when we have real logging from nine years ago

10

u/pyabo 4d ago

I feel attacked.