Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would caution against this.</p> <p>Internal errors are not recoverable. If you divide by zero or whatever - the program is not recoverable.</p> <p>If you turn a termination handler into something that continues the program running, you can have no assurances of the <strong><em>STATE</em></strong> of the program, and you can just crash and corrupt in different ways later. Imagine that the program was holding some <strong><em>locks</em></strong> or other resources at the time of the termination you diverted, for example!</p> <p>Lets have a nasty example:</p> <pre><code>void log(const char* fmt,...) { lock(logfile); va_args... fvprintf(logfile,fmt,__... &lt;--- this line calls the terminator unlock(logfile); } </code></pre> <p>What happens if you don't terminate the program? What happens to the program the next time someone tries to log something?</p> <p>I cannot emphasise this enough - you should use hooking termination methods for extra logging and such, and nothing else. You should always continue to exit afterwards.</p> <hr/> <p>There is a completely different class of error, that can be intercepted:</p> <p>A lot of APIs communicate with the caller using return codes to signal error conditions. It is appropriate to use macros or helper functions to check these return codes and translate them into exceptions. This is because that choice is in your code where you can see it.</p> <p>If you override the _set_errno handler or something, you'd cause code you hadn't wrote that expected the setter to return normally to not return, and it might not have completed its cleanup.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload