title: Getting opencv error in c++
body: <p>I'm try to get the error of opencv! say I have this program: </p>
  
  <pre><code>#include &lt;opencv2\core\core.hpp&gt;
  #include &lt;opencv2\highgui\highgui.hpp&gt;
  
  int main (){
      cv::Mat frame;
      cv::VideoCapture cap(1); // I don't have a second videoinput device! 
      int key = 0; 
  
      while(key !=27){
          cap &gt;&gt; frame;
          cv::imshow("frame",frame);
          key = cv::waitKey(10);
      }
  
      cap.release();
      return 0;
  }
  </code></pre>
  
  <p>when I run this program I  get in the console this message :</p>
  
  <pre><code>OpenCV Error: Assertion failed (size.width&gt;0 &amp;&amp; size.height&gt;0) in unknown functi
  on, file ..\..\..\opencv\modules\highgui\src\window.cpp, line 261
  </code></pre>
  
  <p>My question is how can I  get this message and save it in a string for every error that I get!
  and if it'S possible escaping the program crash! </p>
  
  <p>thanks in advance! </p>