V8 Project
v8::Message Class Reference

An error message. More...

#include <v8.h>

+ Collaboration diagram for v8::Message:

Public Member Functions

Local< StringGet () const
 
Local< StringGetSourceLine () const
 
ScriptOrigin GetScriptOrigin () const
 Returns the origin for the script from where the function causing the error originates. More...
 
Handle< ValueGetScriptResourceName () const
 Returns the resource name for the script from where the function causing the error originates. More...
 
Handle< StackTraceGetStackTrace () const
 Exception stack trace. More...
 
int GetLineNumber () const
 Returns the number, 1-based, of the line where the error occurred. More...
 
int GetStartPosition () const
 Returns the index within the script of the first character where the error occurred. More...
 
int GetEndPosition () const
 Returns the index within the script of the last character where the error occurred. More...
 
int GetStartColumn () const
 Returns the index within the line of the first character where the error occurred. More...
 
int GetEndColumn () const
 Returns the index within the line of the last character where the error occurred. More...
 
bool IsSharedCrossOrigin () const
 Passes on the value set by the embedder when it fed the script from which this Message was generated to V8. More...
 

Static Public Member Functions

static void PrintCurrentStackTrace (Isolate *isolate, FILE *out)
 

Static Public Attributes

static const int kNoLineNumberInfo = 0
 
static const int kNoColumnInfo = 0
 
static const int kNoScriptIdInfo = 0
 

Detailed Description

An error message.

Definition at line 1233 of file v8.h.

Member Function Documentation

◆ Get()

Local< String > v8::Message::Get ( ) const

Definition at line 2059 of file api.cc.

2059  {
2060  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2061  ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
2062  ENTER_V8(isolate);
2063  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2065  i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
2066  Local<String> result = Utils::ToLocal(raw_result);
2067  return scope.Escape(result);
2068 }
#define ON_BAILOUT(isolate, location, code)
Definition: api.cc:60
#define ENTER_V8(isolate)
Definition: api.cc:54
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288
static Handle< String > GetMessage(Isolate *isolate, Handle< Object > data)
Definition: messages.cc:129

References ENTER_V8, v8::EscapableHandleScope::Escape(), v8::internal::MessageHandler::GetMessage(), ON_BAILOUT, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ GetEndColumn()

int v8::Message::GetEndColumn ( ) const

Returns the index within the line of the last character where the error occurred.

Definition at line 2187 of file api.cc.

2187  {
2188  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2189  ON_BAILOUT(isolate, "v8::Message::GetEndColumn()", return kNoColumnInfo);
2190  ENTER_V8(isolate);
2191  i::HandleScope scope(isolate);
2192  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2193  EXCEPTION_PREAMBLE(isolate);
2194  i::Handle<i::Object> start_col_obj;
2195  has_pending_exception = !CallV8HeapFunction(
2196  "GetPositionInLine", data_obj).ToHandle(&start_col_obj);
2197  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2200  int start = message->start_position();
2201  int end = message->end_position();
2202  return static_cast<int>(start_col_obj->Number()) + (end - start);
2203 }
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:93
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:67
static const int kNoColumnInfo
Definition: v8.h:1296
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static MUST_USE_RESULT i::MaybeHandle< i::Object > CallV8HeapFunction(const char *name, i::Handle< i::Object > recv, int argc, i::Handle< i::Object > argv[])
Definition: api.cc:2112

References v8::CallV8HeapFunction(), v8::internal::Handle< T >::cast(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, kNoColumnInfo, ON_BAILOUT, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ GetEndPosition()

int v8::Message::GetEndPosition ( ) const

Returns the index within the script of the last character where the error occurred.

Definition at line 2162 of file api.cc.

2162  {
2163  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2164  ENTER_V8(isolate);
2165  i::HandleScope scope(isolate);
2168  return message->end_position();
2169 }

References v8::internal::Handle< T >::cast(), ENTER_V8, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ GetLineNumber()

int v8::Message::GetLineNumber ( ) const

Returns the number, 1-based, of the line where the error occurred.

Definition at line 2137 of file api.cc.

2137  {
2138  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2139  ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo);
2140  ENTER_V8(isolate);
2141  i::HandleScope scope(isolate);
2142 
2143  EXCEPTION_PREAMBLE(isolate);
2144  i::Handle<i::Object> result;
2145  has_pending_exception = !CallV8HeapFunction(
2146  "GetLineNumber", Utils::OpenHandle(this)).ToHandle(&result);
2147  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2148  return static_cast<int>(result->Number());
2149 }
static const int kNoLineNumberInfo
Definition: v8.h:1295

References v8::CallV8HeapFunction(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, kNoLineNumberInfo, ON_BAILOUT, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ GetScriptOrigin()

ScriptOrigin v8::Message::GetScriptOrigin ( ) const

Returns the origin for the script from where the function causing the error originates.

Definition at line 2071 of file api.cc.

2071  {
2072  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2075  i::Handle<i::Object> script_wraper =
2076  i::Handle<i::Object>(message->script(), isolate);
2077  i::Handle<i::JSValue> script_value =
2078  i::Handle<i::JSValue>::cast(script_wraper);
2079  i::Handle<i::Script> script(i::Script::cast(script_value->value()));
2081  v8::Isolate* v8_isolate =
2082  reinterpret_cast<v8::Isolate*>(script->GetIsolate());
2083  v8::ScriptOrigin origin(
2084  Utils::ToLocal(scriptName),
2085  v8::Integer::New(v8_isolate, script->line_offset()->value()),
2086  v8::Integer::New(v8_isolate, script->column_offset()->value()),
2087  Handle<Boolean>(),
2088  v8::Integer::New(v8_isolate, script->id()->value()));
2089  return origin;
2090 }
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6281
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
The origin, within a file, of a script.
Definition: v8.h:922
static Handle< Object > GetNameOrSourceURL(Handle< Script > script)
Definition: objects.cc:9697

References v8::internal::Handle< T >::cast(), v8::internal::Script::GetNameOrSourceURL(), v8::Integer::New(), v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

Referenced by GetScriptResourceName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetScriptResourceName()

v8::Handle< Value > v8::Message::GetScriptResourceName ( ) const

Returns the resource name for the script from where the function causing the error originates.

Definition at line 2093 of file api.cc.

2093  {
2094  return GetScriptOrigin().ResourceName();
2095 }
ScriptOrigin GetScriptOrigin() const
Returns the origin for the script from where the function causing the error originates.
Definition: api.cc:2071
Handle< Value > ResourceName() const
Definition: v8.h:6365

References GetScriptOrigin(), and v8::ScriptOrigin::ResourceName().

+ Here is the call graph for this function:

◆ GetSourceLine()

Local< String > v8::Message::GetSourceLine ( ) const

Definition at line 2219 of file api.cc.

2219  {
2220  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2221  ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
2222  ENTER_V8(isolate);
2223  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2224  EXCEPTION_PREAMBLE(isolate);
2225  i::Handle<i::Object> result;
2226  has_pending_exception = !CallV8HeapFunction(
2227  "GetSourceLine", Utils::OpenHandle(this)).ToHandle(&result);
2228  EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>());
2229  if (result->IsString()) {
2230  return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(result)));
2231  } else {
2232  return Local<String>();
2233  }
2234 }

References v8::CallV8HeapFunction(), ENTER_V8, v8::EscapableHandleScope::Escape(), EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, ON_BAILOUT, v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ GetStackTrace()

v8::Handle< v8::StackTrace > v8::Message::GetStackTrace ( ) const

Exception stack trace.

By default stack traces are not captured for uncaught exceptions. SetCaptureStackTraceForUncaughtExceptions allows to change this option.

Definition at line 2098 of file api.cc.

2098  {
2099  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2100  ENTER_V8(isolate);
2101  EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2104  i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
2105  if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
2106  i::Handle<i::JSArray> stackTrace =
2107  i::Handle<i::JSArray>::cast(stackFramesObj);
2108  return scope.Escape(Utils::StackTraceToLocal(stackTrace));
2109 }
An object reference managed by the v8 garbage collector.
Definition: v8.h:198
static Local< StackTrace > StackTraceToLocal(v8::internal::Handle< v8::internal::JSArray > obj)

References v8::internal::Handle< T >::cast(), ENTER_V8, v8::EscapableHandleScope::Escape(), v8::Utils::OpenHandle(), and v8::Utils::StackTraceToLocal().

+ Here is the call graph for this function:

◆ GetStartColumn()

int v8::Message::GetStartColumn ( ) const

Returns the index within the line of the first character where the error occurred.

Definition at line 2172 of file api.cc.

2172  {
2173  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2174  ON_BAILOUT(isolate, "v8::Message::GetStartColumn()", return kNoColumnInfo);
2175  ENTER_V8(isolate);
2176  i::HandleScope scope(isolate);
2177  i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2178  EXCEPTION_PREAMBLE(isolate);
2179  i::Handle<i::Object> start_col_obj;
2180  has_pending_exception = !CallV8HeapFunction(
2181  "GetPositionInLine", data_obj).ToHandle(&start_col_obj);
2182  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2183  return static_cast<int>(start_col_obj->Number());
2184 }

References v8::CallV8HeapFunction(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, kNoColumnInfo, ON_BAILOUT, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ GetStartPosition()

int v8::Message::GetStartPosition ( ) const

Returns the index within the script of the first character where the error occurred.

Definition at line 2152 of file api.cc.

2152  {
2153  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2154  ENTER_V8(isolate);
2155  i::HandleScope scope(isolate);
2158  return message->start_position();
2159 }

References v8::internal::Handle< T >::cast(), ENTER_V8, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsSharedCrossOrigin()

bool v8::Message::IsSharedCrossOrigin ( ) const

Passes on the value set by the embedder when it fed the script from which this Message was generated to V8.

Definition at line 2206 of file api.cc.

2206  {
2207  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2208  ENTER_V8(isolate);
2209  i::HandleScope scope(isolate);
2212  i::Handle<i::JSValue> script =
2214  isolate));
2215  return i::Script::cast(script->value())->is_shared_cross_origin();
2216 }

References v8::internal::Handle< T >::cast(), ENTER_V8, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ PrintCurrentStackTrace()

void v8::Message::PrintCurrentStackTrace ( Isolate isolate,
FILE *  out 
)
static

Definition at line 2237 of file api.cc.

2237  {
2238  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2239  ENTER_V8(i_isolate);
2240  i_isolate->PrintCurrentStackTrace(out);
2241 }
void PrintCurrentStackTrace(FILE *out)
Definition: isolate.cc:904

References ENTER_V8, and v8::internal::Isolate::PrintCurrentStackTrace().

+ Here is the call graph for this function:

Member Data Documentation

◆ kNoColumnInfo

const int v8::Message::kNoColumnInfo = 0
static

Definition at line 1296 of file v8.h.

Referenced by v8::StackFrame::GetColumn(), GetEndColumn(), and GetStartColumn().

◆ kNoLineNumberInfo

const int v8::Message::kNoLineNumberInfo = 0
static

Definition at line 1295 of file v8.h.

Referenced by GetLineNumber(), and v8::StackFrame::GetLineNumber().

◆ kNoScriptIdInfo

const int v8::Message::kNoScriptIdInfo = 0
static

Definition at line 1297 of file v8.h.

Referenced by v8::StackFrame::GetScriptId().


The documentation for this class was generated from the following files: