title: How to catch divide-by-zero error in Visual Studio 2008 C++?
body: <p>How can I catch a divide-by-zero error (and not other errors; and to be able to access exception information) in Visual Studio 2008 C++?</p>
  
  <p>I tried this:</p>
  
  <pre><code>try {
    int j=0;
    int i= 1/j;//actually, we call a DLL here, which has divide-by-zero
  } catch(std::exception&amp; e){
    printf("%s %s\n", e.what()); 
  }  catch(...){
    printf("generic exception");
  }
  </code></pre>
  
  <p>But this goes to the generic ... catch block. I understand that the MS-specific __try  may  be useful here, but I'd prefer standard C++, and in any case I have destructors which prevent the use of __try.</p>
  
  <p>CLARIFICATION: The code above is simplified for discussion purposes. Actually, the divide-by-zero is a bug which occurs deep in a third-party DLL for which I do not have the source code. The error depends on the parameter (a handle to a complex structure) which I pass to the library, but not in any obvious way. So, I want to be able to recover gracefully.</p>