title: Properly terminating program. Using exceptions
body: <p><strong>Question</strong>:</p>
  <p>Is using exceptions the proper way to terminate my program if all I want is to display an error message and close (accounting that I may be deep in the program)? Or can I just explicitly call something like <code>exit(EXIT_FAILURE)</code> instead?</p>
  <p><strong>What I'm Currently Doing:</strong></p>
  <p>I'm working on a game project and am trying to figure out the best way to terminate the program in the case of an error that calls for such an action. For example, in the case the textures can't be loaded I display an error message and terminate the program.</p>
  <p>I'm currently doing this with exceptions like so:</p>
  <pre><code>int main()
  {
     Game game;
     try
     {
         game.run();
     }
     catch (BadResolutionException &amp; e)
     {
         Notification::showErrorMessage(e.what(), &quot;ERROR: Resolution&quot;);
         return 1;
     }
     catch (BadAssetException &amp; e)
     {
         Notification::showErrorMessage(e.what(), &quot;ERROR: Assets&quot;);
         return 1;
     }
     catch (std::bad_alloc &amp; e)
     {
         Notification::showErrorMessage(e.what(), &quot;ERROR: Memory&quot;);
         return 1;
     }
     return 0;
  }
  </code></pre>
  <p>All but bad_alloc are my own defined exceptions derived from runtime_error.</p>
  <p>I don't need any manual resource cleanup and I'm using std::unique_ptr for any dynamic allocation. I just need to display the error message and close the program.</p>
  <p><strong>Research/Alternatives to Exceptions:</strong></p>
  <p>I've looked up a lot of posts on SO and other places and have seen others say anything from don't use exceptions, to use exceptions but your using them wrong. I've also looked up explicitly calling something like exit().</p>
  <p><strong>Using exit()</strong> sounds nice but I read it won't go back through the call stack up to main cleaning everything up (if I can find this again I'll post the link). Additionally, according to <a href="http://www.cplusplus.com/reference/cstdlib/exit/" rel="nofollow noreferrer">http://www.cplusplus.com/reference/cstdlib/exit/</a> this should not be used if multiple threads are active. I do expect to be creating a second thread for a short time at least once, and an error could occur in that thread.</p>
  <p><strong>Not using exceptions</strong> was mentioned in some replies here in relation to games <a href="https://gamedev.stackexchange.com/questions/103285/how-industy-games-handle-their-code-errors-and-exceptions">https://gamedev.stackexchange.com/questions/103285/how-industy-games-handle-their-code-errors-and-exceptions</a></p>
  <p><strong>Use exceptions</strong> was discussed here: <a href="http://www.quora.com/Why-do-some-people-recommend-not-using-exception-handling-in-C++" rel="nofollow noreferrer">http://www.quora.com/Why-do-some-people-recommend-not-using-exception-handling-in-C++</a></p>
  <p>There are a number of other sources I've read but those were the most recent I looked at.</p>
  <p><strong>Personal Conclusion:</strong></p>
  <p>Due to my limited experience of working with error handling and using exceptions, I'm not sure if I'm on the right track. I've chosen the route of using exceptions based on the code I posted above. If you agree that I should tackle those cases with exceptions, am I using it correctly?</p>