// Generate the message if required.
if (requires_message && !rethrowing_message) {
- MessageLocation potential_computed_location;
- if (location == NULL) {
- // If no location was specified we use a computed one instead.
- ComputeLocation(&potential_computed_location);
- location = &potential_computed_location;
+ MessageLocation computed_location;
+ // If no location was specified we try to use a computed one instead.
+ if (location == NULL && ComputeLocation(&computed_location)) {
+ location = &computed_location;
}
if (bootstrapper()->IsActive()) {
}
-void Isolate::ComputeLocation(MessageLocation* target) {
- *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
+bool Isolate::ComputeLocation(MessageLocation* target) {
StackTraceFrameIterator it(this);
if (!it.done()) {
JavaScriptFrame* frame = it.frame();
// Compute the location from the function and the reloc info.
Handle<Script> casted_script(Script::cast(script));
*target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
+ return true;
}
}
+ return false;
}
bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
Handle<Object> exception) {
- *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
-
if (!exception->IsJSObject()) return false;
Handle<Name> key = factory()->stack_trace_symbol();
Handle<Object> property =
Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception,
MessageLocation* location) {
Handle<JSArray> stack_trace_object;
- MessageLocation potential_computed_location;
if (capture_stack_trace_for_uncaught_exceptions_) {
if (IsErrorObject(exception)) {
// We fetch the stack trace that corresponds to this error object.
stack_trace_for_uncaught_exceptions_options_);
}
}
- if (!location) {
- if (!ComputeLocationFromException(&potential_computed_location,
- exception)) {
- if (!ComputeLocationFromStackTrace(&potential_computed_location,
- exception)) {
- ComputeLocation(&potential_computed_location);
- }
- }
- location = &potential_computed_location;
+ MessageLocation computed_location;
+ if (location == NULL &&
+ (ComputeLocationFromException(&computed_location, exception) ||
+ ComputeLocationFromStackTrace(&computed_location, exception) ||
+ ComputeLocation(&computed_location))) {
+ location = &computed_location;
}
return MessageHandler::MakeMessageObject(
Handle<JSMessageObject> MessageHandler::MakeMessageObject(
- Isolate* isolate, MessageTemplate::Template message, MessageLocation* loc,
- Handle<Object> argument, Handle<JSArray> stack_frames) {
+ Isolate* isolate, MessageTemplate::Template message,
+ MessageLocation* location, Handle<Object> argument,
+ Handle<JSArray> stack_frames) {
Factory* factory = isolate->factory();
- int start = 0;
- int end = 0;
+ int start = -1;
+ int end = -1;
Handle<Object> script_handle = factory->undefined_value();
- if (loc) {
- start = loc->start_pos();
- end = loc->end_pos();
- script_handle = Script::GetWrapper(loc->script());
+ if (location != NULL) {
+ start = location->start_pos();
+ end = location->end_pos();
+ script_handle = Script::GetWrapper(location->script());
+ } else {
+ script_handle = Script::GetWrapper(isolate->factory()->empty_script());
}
Handle<Object> stack_frames_handle = stack_frames.is_null()
public:
// Returns a message object for the API to use.
static Handle<JSMessageObject> MakeMessageObject(
- Isolate* isolate, MessageTemplate::Template type, MessageLocation* loc,
- Handle<Object> argument, Handle<JSArray> stack_frames);
+ Isolate* isolate, MessageTemplate::Template type,
+ MessageLocation* location, Handle<Object> argument,
+ Handle<JSArray> stack_frames);
// Report a formatted message (needs JS allocation).
static void ReportMessage(Isolate* isolate, MessageLocation* loc,