title: What type of exception should I throw?
body: <p>After going through some links on exception handling (<a href="http://msdn.microsoft.com/en-us/library/hatewcfd(VS.71).aspx" rel="nofollow noreferrer">1</a>, <a href="http://www.cplusplus.com/reference/std/exception/exception/" rel="nofollow noreferrer">2</a>, and <a href="http://www.cplusplus.com/doc/tutorial/exceptions/" rel="nofollow noreferrer">3</a>), I know that C++ programs can throw pretty much anything as exceptions (<code>int</code>, <code>char*</code>, <code>string</code>, <code>exception</code> class). I know that <code>std::exception</code> is the base class for standard exceptions thrown by the program. However, I'm trying to design a <code>try</code>...<code>catch</code> block as such:</p>
  
  <pre><code>try
  {
      MyFunc();
  }
  catch (certain exceptions)
  {
      // deal with the exception accordingly
  }
  catch (the rest of the exceptions)
  {
      // deal with these accordingly
  }
  </code></pre>
  
  <p>while <code>MyFunc()</code> contains the following:</p>
  
  <pre><code>void MyFunc()
  {
      ...
      if (certain condition is true) throw exception;
      ...
  }
  </code></pre>
  
  <p>The trouble is that in that part of <code>MyFunc</code> function, I'm not sure what type of exception I should throw. To keep the code clean by implementing my own exceptions class, I have no idea what would be a good way to implement such exceptions class. </p>