Program logic bugs vs input/environmental errors

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 24 11:29:43 PDT 2014


On 9/27/14, 8:15 PM, Walter Bright wrote:
> This issue comes up over and over, in various guises. I feel like
> Yosemite Sam here:
>
>      https://www.youtube.com/watch?v=hBhlQgvHmQ0
>
> In that vein, Exceptions are for either being able to recover from
> input/environmental errors, or report them to the user of the application.
>
> When I say "They are NOT for debugging programs", I mean they are NOT
> for debugging programs.
>
> assert()s and contracts are for debugging programs.

Here's another +1 for exceptions.

I want to add a a slash command to Slack 
(https://slack.zendesk.com/hc/en-us/articles/201259356-Slash-Commands). 
So, for example, when I say:

/bot random phrase

This hits a web server that processes that request and returns a random 
phrase.

Now, imagine I have an assert in my application. When the web server 
hits the assertion it shuts down and the user doesn't get a response. 
What I'd like to do is to trap that assertion, tell the user that 
there's a problem, and send me an email telling me to debug it and fix 
it. That way the user can continue using the bot and I meanwhile I can 
fix the bug.

In the real world where you don't want unhappy users, asserts don't work.

Walter: how can you do that with an assertion triggering?


More information about the Digitalmars-d mailing list