<p dir="auto">This is a library-wide problem. When the following is used:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="try {
  something();
} catch (e) {
  throw new SomethingError(e);
}"><pre class="notranslate"><span class="pl-k">try</span> {
  <span class="pl-en">something</span>();
} <span class="pl-k">catch</span> (e) {
  <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-c1">SomethingError</span>(e);
}</pre></div>
<p dir="auto">The stack trace loses all context of what in <code class="notranslate">something()</code> caused the original exception. It makes debugging a lot more difficult.</p>
<p dir="auto">++ <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/yjbanov/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/yjbanov">@yjbanov</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mhevery/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mhevery">@mhevery</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="try {
  ...
} catch (e) {
  console.log(e, e.stack);
   throw e;
}"><pre class="notranslate"><span class="pl-k">try</span> <span class="pl-kos">{</span>
  ...
<span class="pl-kos">}</span> <span class="pl-k">catch</span> <span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">,</span> <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">stack</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
   <span class="pl-k">throw</span> <span class="pl-s1">e</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">should transpile to</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="try {
  ...
} catch (e, e_stack) {
  console.log(e, e_stack);
  rethrow;
}"><pre class="notranslate"><span class="pl-k">try</span> {
  ...
} <span class="pl-k">catch</span> (e, e_stack) {
  console.<span class="pl-en">log</span>(e, e_stack);
  <span class="pl-k">rethrow</span>;
}</pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> detect <code class="notranslate">e.stack</code> replace with <code class="notranslate">e_stack</code> + add <code class="notranslate">e_stack</code> to <code class="notranslate">catch</code></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> detect rethrow <code class="notranslate">throw e</code> replace with <code class="notranslate">rethrow</code>;</li>
</ul>