title: Getting stack data from Error Objects in React Native - Expo - CRNA
body: <p>I would like to be able to get the stack data (fileName and lineNumber) from an Error object in React Native.<br>
  If I run something like this: </p>
  
  <pre><code>const err = new Error('Message');
  console.log(err);
  </code></pre>
  
  <p>I get some helpful output in my console like this:</p>
  
  <pre><code>Message
  * App.js:21:16 in componentDidMount
  - node_modules\react-proxy\modules\createPrototypeProxy.js:61:45 in proxiedComponentDidMount
  - node_modules\react-native\Libraries\Renderer\ReactNativeRenderer-dev.js:10627:12 in commitLifeCycles
  - ... 23 more stack frames from framework internals
  </code></pre>
  
  <p>I would like to be able to send that stack data off elsewhere for logging and fixing, but I can't figure out how to access the data which shows the filename and the line where the error was generated.<br>
  How can I get that information?<br>
  As per the documentation <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error" rel="nofollow noreferrer">Error - JavaScript   MDN</a>, if I try:</p>
  
  <pre><code>console.log(err.fileName)
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>console.log(err.lineNumber)
  </code></pre>
  
  <p>I just get:</p>
  
  <pre><code>undefined
  </code></pre>
  
  <p>Which is confirmed by:</p>
  
  <pre><code>console.log(Object.keys(err));
  </code></pre>
  
  <p>resulting in:</p>
  
  <pre><code>Array []
  </code></pre>
  
  <p>Although, mysteriously:</p>
  
  <pre><code>console.log(err.message);
  </code></pre>
  
  <p>still returns:</p>
  
  <pre><code>Message
  </code></pre>
  
  <p>Related - if I enter:</p>
  
  <pre><code>console.log(err.toString())
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Error: Message
  </code></pre>
  
  <p>Similarly, if I enter:</p>
  
  <pre><code>console.log('Comment', err);
  </code></pre>
  
  <p>I get as output:</p>
  
  <pre><code>Comment [Error: Message]
  </code></pre>
  
  <p>So while I can see the stack data is there, I don't seem to be able to access it or pass it somewhere else.</p>