0

There are some paths that I want to throw an Exception when I'm working / debugging, but pass (and Log an error) when in Release.

This means:

  • while working/debugging I can investigate the call stack when this happens
  • this is mainly a cosmetic issue, so in Release people will just see an ugly text instead of the whole application crashing.

Is there already a builtin concept for this? Or any "word" that I can look for?

I know about Asserts, but as far as I know they are completely stripped on Release for performance reasons.

I just want this case to Log on Release.

I am mainly working in C#, but I can imagine this ia general concept.

If there is nothing there I can quite easily built it myself, but I prefer using industry standards.

3
  • 2
    Debugger.IsAttached (learn.microsoft.com/en-us/dotnet/api/…) may do what you need. Commented Jan 11, 2024 at 21:38
  • Also Debugger.Break() if you just want to break and inspect things without throwing an Exception. Commented Jan 12, 2024 at 1:00
  • Also, you can develop alternative behavior for different configurations, exceptions vs logging, for example, using #if DEBUG ... Commented Jan 14 at 5:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.