Commit 89403e03 authored by jgruber's avatar jgruber Committed by Commit bot

Omit frames up to new target in Error constructor

BUG=v8:5216
R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2175603003
Cr-Commit-Position: refs/heads/master@{#37978}
parent 871bb728
...@@ -502,9 +502,19 @@ MaybeHandle<Object> ConstructError(Isolate* isolate, Handle<JSFunction> target, ...@@ -502,9 +502,19 @@ MaybeHandle<Object> ConstructError(Isolate* isolate, Handle<JSFunction> target,
RETURN_ON_EXCEPTION(isolate, isolate->CaptureAndSetDetailedStackTrace(err), RETURN_ON_EXCEPTION(isolate, isolate->CaptureAndSetDetailedStackTrace(err),
Object); Object);
} }
// When we're passed a JSFunction as new target, we can skip frames until that
// specific function is seen instead of unconditionally skipping the first
// frame.
Handle<Object> caller;
if (mode == SKIP_FIRST && new_target->IsJSFunction()) {
mode = SKIP_UNTIL_SEEN;
caller = new_target;
}
// Capture a simple stack trace for the stack property. // Capture a simple stack trace for the stack property.
RETURN_ON_EXCEPTION(isolate, isolate->CaptureAndSetSimpleStackTrace( RETURN_ON_EXCEPTION(isolate,
err, mode, Handle<Object>()), isolate->CaptureAndSetSimpleStackTrace(err, mode, caller),
Object); Object);
return err; return err;
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Ensure that custom error constructors don't show up in stack traces.
class MyError extends Error { }
assertFalse(new MyError().stack.includes("at MyError"));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment