소스 검색

Avoid capturing stack trace twice

Co-authored-by: Eric Mc Sween <eric.mcsween@overleaf.com>
John Lees-Miller 6 년 전
부모
커밋
fc197630be
1개의 변경된 파일과 8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      libraries/o-error/index.js

+ 8 - 4
libraries/o-error/index.js

@@ -54,10 +54,14 @@ class OError extends Error {
 
     if (!oError._oErrorTags) oError._oErrorTags = []
 
-    const tag = new TaggedError(message, info)
-
-    // Hide this function in the stack trace.
-    if (Error.captureStackTrace) Error.captureStackTrace(tag, OError.tag)
+    let tag
+    if (Error.captureStackTrace) {
+      // Hide this function in the stack trace.
+      tag = { name: 'TaggedError', message, info }
+      Error.captureStackTrace(tag, OError.tag)
+    } else {
+      tag = new TaggedError(message, info)
+    }
 
     oError._oErrorTags.push(tag)