本文整理汇总了C++中ErrorEvent类的典型用法代码示例。如果您正苦于以下问题:C++ ErrorEvent类的具体用法?C++ ErrorEvent怎么用?C++ ErrorEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
void handleEvent(NodeManagerEvent *e)
{
SystemTreeEvent *treeEvent;
ErrorEvent *errorEvent;
JausMessageEvent *messageEvent;
switch(e->getType())
{
case NodeManagerEvent::SystemTreeEvent:
treeEvent = (SystemTreeEvent *)e;
printf("%s\n", treeEvent->toString().c_str());
delete e;
break;
case NodeManagerEvent::ErrorEvent:
errorEvent = (ErrorEvent *)e;
printf("%s\n", errorEvent->toString().c_str());
delete e;
break;
case NodeManagerEvent::JausMessageEvent:
messageEvent = (JausMessageEvent *)e;
// TODO: Make this useful somehow
// If you turn this on, the system gets spam-y this is just a test of the message event
//printf("%s\n", messageEvent->toString().c_str());
delete e;
break;
default:
delete e;
break;
}
}
示例2: jsErrorEventPrototypeFunctionInitErrorEvent
EncodedJSValue JSC_HOST_CALL jsErrorEventPrototypeFunctionInitErrorEvent(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSErrorEvent::s_info))
return throwVMTypeError(exec);
JSErrorEvent* castedThis = static_cast<JSErrorEvent*>(asObject(thisValue));
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSErrorEvent::s_info);
ErrorEvent* imp = static_cast<ErrorEvent*>(castedThis->impl());
const String& typeArg(ustringToString(exec->argument(0).toString(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
bool canBubbleArg(exec->argument(1).toBoolean(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
bool cancelableArg(exec->argument(2).toBoolean(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
const String& messageArg(ustringToString(exec->argument(3).toString(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
const String& filenameArg(ustringToString(exec->argument(4).toString(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
unsigned linenoArg(exec->argument(5).toUInt32(exec));
if (exec->hadException())
return JSValue::encode(jsUndefined());
imp->initErrorEvent(typeArg, canBubbleArg, cancelableArg, messageArg, filenameArg, linenoArg);
return JSValue::encode(jsUndefined());
}
示例3: getListenerObject
v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(v8::Handle<v8::Value> jsEvent, Event* event)
{
if (!event->hasInterface(EventNames::ErrorEvent))
return V8EventListener::callListenerFunction(jsEvent, event);
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
if (errorEvent->world() && errorEvent->world() != &world())
return v8::Null(isolate());
v8::Local<v8::Object> listener = getListenerObject(scriptState()->executionContext());
v8::Local<v8::Value> returnValue;
if (!listener.IsEmpty() && listener->IsFunction()) {
v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
v8::Local<v8::Object> thisValue = scriptState()->context()->Global();
v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), jsEvent->ToObject(), V8HiddenValue::error(isolate()));
if (error.IsEmpty())
error = v8::Null(isolate());
v8::Handle<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error };
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
returnValue = ScriptController::callFunction(scriptState()->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
}
return returnValue;
}
示例4: jsErrorEventFilename
JSValue jsErrorEventFilename(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSErrorEvent* castedThis = static_cast<JSErrorEvent*>(asObject(slotBase));
UNUSED_PARAM(exec);
ErrorEvent* imp = static_cast<ErrorEvent*>(castedThis->impl());
JSValue result = jsString(exec, imp->filename());
return result;
}
示例5: jsErrorEventLineno
JSValue jsErrorEventLineno(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSErrorEvent* castedThis = static_cast<JSErrorEvent*>(asObject(slotBase));
UNUSED_PARAM(exec);
ErrorEvent* imp = static_cast<ErrorEvent*>(castedThis->impl());
JSValue result = jsNumber(imp->lineno());
return result;
}
示例6: ASSERT
void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
JSLock lock(SilenceAssertionsOnly);
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->getCallData(callData);
if (callType != CallTypeNone) {
ref();
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
ASSERT(event->isErrorEvent());
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
MarkedArgumentBuffer args;
args.append(jsString(exec, errorEvent->message()));
args.append(jsString(exec, errorEvent->filename()));
args.append(jsNumber(exec, errorEvent->lineno()));
JSGlobalData* globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject);
JSValue thisValue = globalObject->toThisObject(exec);
globalData->timeoutChecker.start();
JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData->timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
if (exec->hadException())
reportCurrentException(exec);
else {
bool retvalbool;
if (returnValue.getBoolean(retvalbool) && !retvalbool)
event->preventDefault();
}
deref();
}
}
示例7: ASSERT
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
if (!event->hasInterface(eventNames().interfaceForErrorEvent))
return JSEventListener::handleEvent(scriptExecutionContext, event);
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
JSLock lock(SilenceAssertionsOnly);
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->methodTable()->getCallData(jsFunction, callData);
if (callType != CallTypeNone) {
RefPtr<JSErrorHandler> protectedctor(this);
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
MarkedArgumentBuffer args;
args.append(jsString(exec, errorEvent->message()));
args.append(jsString(exec, errorEvent->filename()));
args.append(jsNumber(errorEvent->lineno()));
JSGlobalData& globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(globalData, globalData.dynamicGlobalObject ? globalData.dynamicGlobalObject : globalObject);
JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec);
globalData.timeoutChecker.start();
JSValue returnValue = scriptExecutionContext->isDocument()
? JSMainThreadExecState::call(exec, jsFunction, callType, callData, thisValue, args)
: JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData.timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
if (exec->hadException())
reportCurrentException(exec);
else {
if (returnValue.isTrue())
event->preventDefault();
}
}
}
示例8: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Local<v8::Message> message,
v8::Local<v8::Value> data) {
ASSERT(isMainThread());
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (isolate->GetEnteredContext().IsEmpty())
return;
// If called during context initialization, there will be no entered context.
ScriptState* scriptState = ScriptState::current(isolate);
if (!scriptState->contextIsValid())
return;
ExecutionContext* context = scriptState->getExecutionContext();
std::unique_ptr<SourceLocation> location =
SourceLocation::fromMessage(isolate, message, context);
AccessControlStatus accessControlStatus = NotSharableCrossOrigin;
if (message->IsOpaque())
accessControlStatus = OpaqueResource;
else if (message->IsSharedCrossOrigin())
accessControlStatus = SharableCrossOrigin;
ErrorEvent* event =
ErrorEvent::create(toCoreStringWithNullCheck(message->Get()),
std::move(location), &scriptState->world());
String messageForConsole = extractMessageForConsole(isolate, data);
if (!messageForConsole.isEmpty())
event->setUnsanitizedMessage("Uncaught " + messageForConsole);
// This method might be called while we're creating a new context. In this
// case, we avoid storing the exception object, as we can't create a wrapper
// during context creation.
// FIXME: Can we even get here during initialization now that we bail out when
// GetEntered returns an empty handle?
if (context->isDocument()) {
LocalFrame* frame = toDocument(context)->frame();
if (frame && frame->script().existingWindowProxy(scriptState->world())) {
V8ErrorHandler::storeExceptionOnErrorEventWrapper(
scriptState, event, data, scriptState->context()->Global());
}
}
if (scriptState->world().isPrivateScriptIsolatedWorld()) {
// We allow a private script to dispatch error events even in a
// EventDispatchForbiddenScope scope. Without having this ability, it's
// hard to debug the private script because syntax errors in the private
// script are not reported to console (the private script just crashes
// silently). Allowing error events in private scripts is safe because
// error events don't propagate to other isolated worlds (which means that
// the error events won't fire any event listeners in user's scripts).
EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;
context->dispatchErrorEvent(event, accessControlStatus);
} else {
context->dispatchErrorEvent(event, accessControlStatus);
}
}
示例9: ASSERT
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
if (event->eventInterface() != ErrorEventInterfaceType)
return JSEventListener::handleEvent(scriptExecutionContext, event);
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
ErrorEvent* errorEvent = toErrorEvent(event);
JSLockHolder lock(scriptExecutionContext->vm());
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->methodTable()->getCallData(jsFunction, callData);
if (callType != CallTypeNone) {
Ref<JSErrorHandler> protectedctor(*this);
Event* savedEvent = globalObject->currentEvent();
globalObject->setCurrentEvent(event);
MarkedArgumentBuffer args;
args.append(jsStringWithCache(exec, errorEvent->message()));
args.append(jsStringWithCache(exec, errorEvent->filename()));
args.append(jsNumber(errorEvent->lineno()));
args.append(jsNumber(errorEvent->colno()));
VM& vm = globalObject->vm();
VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
JSValue returnValue = scriptExecutionContext->isDocument()
? JSMainThreadExecState::call(exec, jsFunction, callType, callData, globalObject, args)
: JSC::call(exec, jsFunction, callType, callData, globalObject, args);
globalObject->setCurrentEvent(savedEvent);
if (exec->hadException())
reportCurrentException(exec);
else {
if (returnValue.isTrue())
event->preventDefault();
}
}
}
示例10: ASSERT
v8::Local<v8::Value> V8WorkerContextErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
ASSERT(event->isErrorEvent());
v8::Local<v8::Object> listener = getListenerObject(context);
v8::Local<v8::Value> returnValue;
if (!listener.IsEmpty() && listener->IsFunction()) {
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), v8String(errorEvent->filename()), v8::Integer::New(errorEvent->lineno()) };
returnValue = callFunction->Call(thisValue, 3, parameters);
}
return returnValue;
}
示例11: v8SetReturnValue
void V8ErrorEvent::errorAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Value> cachedError = V8HiddenValue::getHiddenValue(ScriptState::current(isolate), info.Holder(), V8HiddenValue::error(isolate));
if (!cachedError.IsEmpty()) {
v8SetReturnValue(info, cachedError);
return;
}
ErrorEvent* event = V8ErrorEvent::toImpl(info.Holder());
ScriptState* scriptState = ScriptState::current(isolate);
ScriptValue error = event->error(scriptState);
if (!error.isEmpty())
setHiddenValueAndReturnValue(scriptState, info, error.v8Value());
else
setHiddenValueAndReturnValue(scriptState, info, v8::Null(isolate));
}
示例12: jsErrorEventPrototypeFunctionInitErrorEvent
JSValue JSC_HOST_CALL jsErrorEventPrototypeFunctionInitErrorEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSErrorEvent::s_info))
return throwError(exec, TypeError);
JSErrorEvent* castedThisObj = static_cast<JSErrorEvent*>(asObject(thisValue));
ErrorEvent* imp = static_cast<ErrorEvent*>(castedThisObj->impl());
const UString& typeArg = args.at(0).toString(exec);
bool canBubbleArg = args.at(1).toBoolean(exec);
bool cancelableArg = args.at(2).toBoolean(exec);
const UString& messageArg = args.at(3).toString(exec);
const UString& filenameArg = args.at(4).toString(exec);
unsigned linenoArg = args.at(5).toInt32(exec);
imp->initErrorEvent(typeArg, canBubbleArg, cancelableArg, messageArg, filenameArg, linenoArg);
return jsUndefined();
}
示例13: switch
void KoreEngine::customEvent( QEvent* event )
{
if( event->type() != KoreEvent::EventType() )
{
Library::customEvent( event );
return; // This is not an event for us !
}
KoreEvent* kEvent = static_cast< KoreEvent* >(event);
switch( kEvent->koreEventType() )
{
case KoreEvent::Error:
{
ErrorEvent* eEvent = static_cast< ErrorEvent* >( kEvent );
emit error( eEvent->error(), eEvent->details() );
}
break;
default:
break;
}
}
示例14: ASSERT
v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptState, v8::Local<v8::Value> jsEvent, Event* event)
{
ASSERT(!jsEvent.IsEmpty());
if (!event->hasInterface(EventNames::ErrorEvent))
return V8EventListener::callListenerFunction(scriptState, jsEvent, event);
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
if (errorEvent->world() && errorEvent->world() != &world())
return v8::Null(isolate());
v8::Local<v8::Object> listener = getListenerObject(scriptState->executionContext());
if (listener.IsEmpty() || !listener->IsFunction())
return v8::Null(isolate());
v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
v8::Local<v8::Object> thisValue = scriptState->context()->Global();
v8::Local<v8::Object> eventObject;
if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject))
return v8::Null(isolate());
v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventObject, V8HiddenValue::error(isolate()));
if (error.IsEmpty())
error = v8::Null(isolate());
v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error };
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
v8::MaybeLocal<v8::Value> result;
if (scriptState->executionContext()->isWorkerGlobalScope()) {
result = V8ScriptRunner::callFunction(callFunction, scriptState->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
} else {
result = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
}
v8::Local<v8::Value> returnValue;
if (!result.ToLocal(&returnValue))
return v8::Null(isolate());
return returnValue;
}
示例15: onError
void CloseIisuServer::onError(const ErrorEvent& event)
{
cerr << "iisu error : " << event.getError().getDescription().ptr() << endl;
getchar();
}