title: how to get error line number in C++ program
body: <p>I want to handle errors in my c++ program, so I created some exception classes to manage those errors, but I want to specify at which line in my program the error occurred.</p>
  
  <p>I passed <strong>LINE</strong> macro to the constructor of my exception class.</p>
  
  <p>For example:</p>
  
  <pre><code>void f(int i){ // LINE A
    if(i&lt;0)
      throw(OutOfRange("message", __LINE__); // LINE B
  }
  
  void main(){
  
    try{
      f(-6); // LINE C
    }
    catch(const OutOfRange&amp; error){
      //do something
    }
  
  }
  </code></pre>
  
  <p>In this example I can only get the LINE B number, but I want to get LINE A and LINE C numbers.</p>
  
  <p>Any idea, where and how to use <strong>LINE</strong> macro ??</p>
  
  <p>Thanks.</p>