• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ JS_GetPendingException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JS_GetPendingException函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_GetPendingException函数的具体用法?C++ JS_GetPendingException怎么用?C++ JS_GetPendingException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JS_GetPendingException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getScope

void MozJSImplScope::_reportError(JSContext* cx, const char* message, JSErrorReport* report) {
    auto scope = getScope(cx);

    if (!JSREPORT_IS_WARNING(report->flags)) {
        str::stream ss;
        ss << message;

        // TODO: something far more elaborate that mimics the stack printing from v8
        JS::RootedValue excn(cx);
        if (JS_GetPendingException(cx, &excn) && excn.isObject()) {
            JS::RootedValue stack(cx);

            ObjectWrapper(cx, excn).getValue("stack", &stack);

            auto str = ValueWriter(cx, stack).toString();

            if (str.empty()) {
                ss << " @" << report->filename << ":" << report->lineno << ":" << report->column
                   << "\n";
            } else {
                ss << " :\n" << str;
            }
        }

        scope->_status = Status(
            JSErrorReportToStatus(cx, report, ErrorCodes::JSInterpreterFailure, message).code(),
            ss);
    }
}
开发者ID:Jaryli,项目名称:mongo,代码行数:29,代码来源:implscope.cpp


示例2: jsd_ThrowHandler

JSTrapStatus
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
                 jsval *rval, void *closure)
{
    JSDScript*      jsdscript;
    JSDContext*     jsdc = (JSDContext*) closure;
    JSD_ExecutionHookProc hook;
    void*                 hookData;

    if( ! jsdc || ! jsdc->inited )
        return JSTRAP_CONTINUE;

    if( JSD_IS_DANGEROUS_THREAD(jsdc) )
        return JSTRAP_CONTINUE;

    /* local in case jsdc->throwHook gets cleared on another thread */
    JSD_LOCK();
    hook     = jsdc->throwHook;
    hookData = jsdc->throwHookData;
    JSD_UNLOCK();
    if (!hook)
        return JSTRAP_CONTINUE;

    JSD_LOCK_SCRIPTS(jsdc);
    jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, JSNullFramePtr());
    JSD_UNLOCK_SCRIPTS(jsdc);
    if( ! jsdscript )
        return JSTRAP_CONTINUE;

    JS_GetPendingException(cx, rval);

    return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
                                 hook, hookData, rval);
}
开发者ID:SlateScience,项目名称:Spidermonkey,代码行数:34,代码来源:jsd_hook.cpp


示例3: INT_TO_JSVAL

void FFSessionHandler::getToStringTearOff(JSContext* ctx) {
  jsval funcVal;

  Debug::log(Debug::Debugging) << "Getting function \"__gwt_makeTearOff\""
        << Debug::flush;

  if (!JS_GetProperty(ctx, global, "__gwt_makeTearOff", &funcVal)
      || funcVal == JSVAL_VOID) {
    Debug::log(Debug::Error) << "Could not get function \"__gwt_makeTearOff\""
        << Debug::flush;
    return;
  }
  jsval jsargs[3] = {
    JSVAL_NULL,                                     // no proxy
    INT_TO_JSVAL(InvokeMessage::TOSTRING_DISP_ID),  // dispId
    JSVAL_ZERO                                      // arg count is zero
  };
  if (!JS_CallFunctionValue(ctx, global, funcVal, 3, jsargs, &toStringTearOff)) {
    jsval exc;
    if (JS_GetPendingException(ctx, &exc)) {
      Debug::log(Debug::Error)
          << "__gwt_makeTearOff(null,0,0) threw exception "
          << dumpJsVal(ctx, exc) << Debug::flush;
    } else {
      Debug::log(Debug::Error) << "Error creating toString tear-off"
          << Debug::flush;
    }
    // TODO(jat): show some crash page and die
  }
}
开发者ID:jnorthrup,项目名称:gwt-sandbox,代码行数:30,代码来源:FFSessionHandler.cpp


示例4: gjs_move_exception

JSBool
gjs_move_exception(JSContext      *src_context,
                   JSContext      *dest_context)
{
    JSBool success;

    JS_BeginRequest(src_context);
    JS_BeginRequest(dest_context);

    /* NOTE: src and dest could be the same. */
    jsval exc;
    if (JS_GetPendingException(src_context, &exc)) {
        if (src_context != dest_context) {
            /* try to add the current stack of dest_context to the
             * stack trace of exc */
            try_to_chain_stack_trace(src_context, dest_context, exc);
            /* move the exception to dest_context */
            JS_SetPendingException(dest_context, exc);
            JS_ClearPendingException(src_context);
        }
        success = JS_TRUE;
    } else {
        success = JS_FALSE;
    }

    JS_EndRequest(dest_context);
    JS_EndRequest(src_context);

    return success;
}
开发者ID:sjokkis,项目名称:gjs,代码行数:30,代码来源:jsapi-util.c


示例5: rq

bool ScriptInterface::ParseJSON(const std::string& string_utf8, JS::MutableHandleValue out)
{
	JSAutoRequest rq(m->m_cx);
	std::wstring attrsW = wstring_from_utf8(string_utf8);
 	utf16string string(attrsW.begin(), attrsW.end());
	if (JS_ParseJSON(m->m_cx, reinterpret_cast<const jschar*>(string.c_str()), (u32)string.size(), out))
		return true;

	LOGERROR("JS_ParseJSON failed!");
	if (!JS_IsExceptionPending(m->m_cx))
		return false;

	JS::RootedValue exc(m->m_cx);
	if (!JS_GetPendingException(m->m_cx, &exc))
		return false;

	JS_ClearPendingException(m->m_cx);
	// We expect an object of type SyntaxError
	if (!exc.isObject())
		return false;

	JS::RootedValue rval(m->m_cx);
	JS::RootedObject excObj(m->m_cx, &exc.toObject());
	if (!JS_CallFunctionName(m->m_cx, excObj, "toString", JS::HandleValueArray::empty(), &rval))
		return false;

	std::wstring error;
	ScriptInterface::FromJSVal(m->m_cx, rval, error);
	LOGERROR("%s", utf8_from_wstring(error));
	return false;
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:31,代码来源:ScriptInterface.cpp


示例6: toval

    jsval toval( const char * c ) {
        JSString * s = JS_NewStringCopyZ( _context , c );
        if ( s )
            return STRING_TO_JSVAL( s );

        // possibly unicode, try manual

        size_t len = strlen( c );
        size_t dstlen = len * 4;
        jschar * dst = (jschar*)malloc( dstlen );

        JSBool res = JS_DecodeBytes( _context , c , len , dst, &dstlen );
        if ( res ) {
            s = JS_NewUCStringCopyN( _context , dst , dstlen );
        }

        free( dst );

        if ( ! res ) {
            cout << "decode failed. probably invalid utf-8 string [" << c << "]" << endl;
            jsval v;
            if ( JS_GetPendingException( _context , &v ) )
                cout << "\t why: " << toString( v ) << endl;
            throw UserException( 9006 , "invalid utf8" );
        }

        assert( s );
        return STRING_TO_JSVAL( s );
    }
开发者ID:xrogaan,项目名称:mongo,代码行数:29,代码来源:engine_spidermonkey.cpp


示例7: FreeDataAndDispatchError

void
FileReader::OnLoadEndArrayBuffer()
{
  AutoJSAPI jsapi;
  if (!jsapi.Init(GetParentObject())) {
    FreeDataAndDispatchError(NS_ERROR_FAILURE);
    return;
  }

  RootResultArrayBuffer();

  JSContext* cx = jsapi.cx();

  mResultArrayBuffer = JS_NewArrayBufferWithContents(cx, mDataLen, mFileData);
  if (mResultArrayBuffer) {
    mFileData = nullptr; // Transfer ownership
    FreeDataAndDispatchSuccess();
    return;
  }

  // Let's handle the error status.

  JS::Rooted<JS::Value> exceptionValue(cx);
  if (!JS_GetPendingException(cx, &exceptionValue) ||
      // This should not really happen, exception should always be an object.
      !exceptionValue.isObject()) {
    JS_ClearPendingException(jsapi.cx());
    FreeDataAndDispatchError(NS_ERROR_OUT_OF_MEMORY);
    return;
  }

  JS_ClearPendingException(jsapi.cx());

  JS::Rooted<JSObject*> exceptionObject(cx, &exceptionValue.toObject());
  JSErrorReport* er = JS_ErrorFromException(cx, exceptionObject);
  if (!er || er->message()) {
    FreeDataAndDispatchError(NS_ERROR_OUT_OF_MEMORY);
    return;
  }

  nsAutoString errorName;
  JSFlatString* name = js::GetErrorTypeName(cx, er->exnType);
  if (name) {
    AssignJSFlatString(errorName, name);
  }

  nsAutoCString errorMsg(er->message().c_str());
  nsAutoCString errorNameC = NS_LossyConvertUTF16toASCII(errorName);
  // XXX Code selected arbitrarily
  mError =
    new DOMException(NS_ERROR_DOM_INVALID_STATE_ERR, errorMsg,
                     errorNameC, DOMException_Binding::INVALID_STATE_ERR);

  FreeDataAndDispatchError();
}
开发者ID:artines1,项目名称:gecko-dev,代码行数:55,代码来源:FileReader.cpp


示例8: PD_TRACE_ENTRY

   // PD_TRACE_DECLARE_FUNCTION ( SDB_SCOPE_EVALUATE2, "Scope::evaluate2" )
   INT32 Scope::evaluate2 ( const CHAR *code, UINT32 len, UINT32 lineno,
                            jsval *rval, CHAR **errMsg,
                            INT32 printFlag )
   {
      PD_TRACE_ENTRY ( SDB_SCOPE_EVALUATE2 );
      INT32 rc = SDB_OK ;
      jsval exception = JSVAL_VOID ;
      CHAR *cstrException = NULL ;
      SDB_ASSERT ( _context && _global, "this scope has not been initilized" ) ;
      SDB_ASSERT ( code , "Invalid arguments" ) ;

      // set error report
      sdbSetPrintError( ( printFlag & SPT_EVAL_FLAG_PRINT ) ? TRUE : FALSE ) ;
      sdbSetNeedClearErrorInfo( TRUE ) ;

      if ( ! JS_EvaluateScript ( _context, _global, code, len, NULL,
                                 lineno, rval ) )
      {
         rc = sdbGetErrno() ? sdbGetErrno() : SDB_SPT_EVAL_FAIL ;
         goto error ;
      }

      // clear return error
      if ( sdbIsNeedClearErrorInfo() &&
           !JS_IsExceptionPending( _context ) )
      {
         sdbClearErrorInfo() ;
      }

   done:
      PD_TRACE_EXITRC ( SDB_SCOPE_EVALUATE2, rc );
      return rc ;
   error:
      if ( JS_IsExceptionPending( _context ) &&
           JS_GetPendingException ( _context , &exception ) )
      {
         cstrException = convertJsvalToString ( _context , exception ) ;
         if ( cstrException )
         {
            if ( printFlag & SPT_EVAL_FLAG_PRINT )
            {
               ossPrintf ( "Uncaught exception: %s\n" , cstrException ) ;
            }

            /// what to do when oom?
            *errMsg = ossStrdup( cstrException ) ;
            SAFE_JS_FREE ( _context , cstrException ) ;
         }
         else
         {
            JS_ClearPendingException ( _context ) ;
         }
      }
      goto done ;
   }
开发者ID:Andrew8305,项目名称:SequoiaDB,代码行数:56,代码来源:engine.cpp


示例9: DriverManager_getConnection

static JSBool DriverManager_getConnection(JSContext *cx, unsigned argc, jsval *vp)
{
	jsval drivers;
	JS_LookupProperty(cx, JS_THIS_OBJECT(cx, vp), "drivers", &drivers);
	// FIXME check return code; check that drivers is an array
	JSObject *obj = JSVAL_TO_OBJECT(drivers);

	uint32_t len, i;
	JS_GetArrayLength(cx, obj, &len);


	jsval connect_argv[2] = {JS_ARGV(cx, vp)[0]};
	if (argc == 2) {
		/* Caller passed "info" object, so we forward it as-is */
		connect_argv[1] = JS_ARGV(cx, vp)[1];
	} else {
		JSObject *info = JS_NewObject(cx, NULL, NULL, NULL); // FIXME root it to avoid GC
		if (argc > 1)
			JS_DefineProperty(cx, info, "user", JS_ARGV(cx, vp)[1], NULL, NULL, JSPROP_ENUMERATE);
		if (argc > 2)
			JS_DefineProperty(cx, info, "password", JS_ARGV(cx, vp)[2], NULL, NULL, JSPROP_ENUMERATE);

		connect_argv[1] = OBJECT_TO_JSVAL(info);
	};

	jsval reason = JSVAL_NULL;
	for (i = 0; i < len; i++) {
		jsval driver, rval;
		JS_GetElement(cx, obj, i, &driver);

		if (!JS_CallFunctionName(cx, JSVAL_TO_OBJECT(driver), "connect", 2, &connect_argv[0], &rval)) {
			if (JSVAL_IS_NULL(reason))
				JS_GetPendingException(cx, &reason);
			continue;
		}
		if (JSVAL_IS_NULL(rval))
			continue;
		JS_SET_RVAL(cx, vp, rval);
		return JS_TRUE;
	}

	if (JSVAL_IS_NULL(reason)) {
		JSString *url_str = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
		// FIXME check return value
		// FIXME root url_str (protect from GC) -> https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_ValueToString
		char *url = JS_EncodeString(cx, url_str);
		JS_ReportError(cx, "No suitable driver found for %s", url);
		JS_free(cx, url);
	} else
		JS_SetPendingException(cx, reason);

	JS_SET_RVAL(cx, vp, JSVAL_NULL);
	return JS_FALSE;
}
开发者ID:mindbit,项目名称:libjssql,代码行数:54,代码来源:jssql.c


示例10: enumerate

static JSBool
enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
          jsval *statep, jsid *idp)
{
  JSObject *iterator;
 
  switch (enum_op) {
  case JSENUMERATE_INIT:
    if (resolverHasMethod(cx, obj, "enumerate")) {
      if (!delegateToResolver(cx, obj, "enumerate", 0, NULL, statep))
        return JS_FALSE;
      if (!JSVAL_IS_OBJECT(*statep)) {
        JS_ReportError(cx, "Expected enumerate() to return an iterator.");
        return JS_FALSE;
      }
      *idp = JSVAL_ZERO;
      JS_AddRoot(cx, statep);
      return JS_TRUE;
    }
    // TODO: Default behavior?
    JS_ReportError(cx, "Enumeration is not implemented on this object.");
    return JS_FALSE;
  case JSENUMERATE_NEXT:
    jsval rval;
    iterator = JSVAL_TO_OBJECT(*statep);
    if (!JS_CallFunctionName(cx, iterator, "next", 0, NULL, &rval)) {
      if (JS_IsExceptionPending(cx)) {
        jsval exception;
        if (!JS_GetPendingException(cx, &exception))
          return JS_FALSE;
        if (!JSVAL_IS_OBJECT(exception))
          return JS_FALSE;
        JSClass *clasp = JS_GET_CLASS(cx, JSVAL_TO_OBJECT(exception));
        if (clasp &&
            JSCLASS_CACHED_PROTO_KEY(clasp) == JSProto_StopIteration) {
          JS_ClearPendingException(cx);
          *statep = JSVAL_NULL;
          JS_RemoveRoot(cx, statep);
          return JS_TRUE;
        }
      }
      return JS_FALSE;
    }
    if (!JS_ValueToId(cx, rval, idp))
      return JS_FALSE;
    return JS_TRUE;
  case JSENUMERATE_DESTROY:
    JS_RemoveRoot(cx, statep);
    return JS_TRUE;
  default:
    JS_ReportError(cx, "Unknown enum_op");
    return JS_FALSE;
  }
}
开发者ID:8planes,项目名称:mirosubs-jetpack,代码行数:54,代码来源:wrapper.cpp


示例11: MOZ_ASSERT_IF

bool
AutoJSAPI::PeekException(JS::MutableHandle<JS::Value> aVal)
{
  MOZ_ASSERT_IF(mIsMainThread, CxPusherIsStackTop());
  MOZ_ASSERT(HasException());
  MOZ_ASSERT(js::GetContextCompartment(cx()));
  if (!JS_GetPendingException(cx(), aVal)) {
    return false;
  }
  return true;
}
开发者ID:benfrancis,项目名称:gecko-tablet,代码行数:11,代码来源:ScriptSettings.cpp


示例12: js_ReportUncaughtException

JSBool
js_ReportUncaughtException(JSContext *cx)
{
    JSObject *exnObject;
    JSString *str;
    jsval exn;
    JSErrorReport *reportp;
    const char *bytes;

    if (!JS_IsExceptionPending(cx))
        return JS_FALSE;

    if (!JS_GetPendingException(cx, &exn))
        return JS_FALSE;

    /*
     * Because js_ValueToString below could error and an exception object
     * could become unrooted, we root it here.
     */
    if (JSVAL_IS_OBJECT(exn) && exn != JSVAL_NULL) {
        exnObject = JSVAL_TO_OBJECT(exn);
        if (!js_AddRoot(cx, &exnObject, "exn.report.root"))
            return JS_FALSE;
    } else {
        exnObject = NULL;
    }

#if JS_HAS_ERROR_EXCEPTIONS
    reportp = js_ErrorFromException(cx, exn);
#else
    reportp = NULL;
#endif

    str = js_ValueToString(cx, exn);
    bytes = str ? js_GetStringBytes(str) : "null";

    if (reportp == NULL) {
        /*
         * XXXmccabe todo: Instead of doing this, synthesize an error report
         * struct that includes the filename, lineno where the exception was
         * originally thrown.
         */
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                             JSMSG_UNCAUGHT_EXCEPTION, bytes);
    } else {
        /* Flag the error as an exception. */
        reportp->flags |= JSREPORT_EXCEPTION;
        js_ReportErrorAgain(cx, bytes, reportp);
    }

    if (exnObject != NULL)
        js_RemoveRoot(cx->runtime, &exnObject);
    return JS_TRUE;
}
开发者ID:DmitrySigaev,项目名称:DSMedia,代码行数:54,代码来源:jsexn.c


示例13: MOZ_ASSERT

bool
AutoJSAPI::StealException(JS::MutableHandle<JS::Value> aVal)
{
    MOZ_ASSERT(CxPusherIsStackTop());
    MOZ_ASSERT(HasException());
    MOZ_ASSERT(js::GetContextCompartment(cx()));
    if (!JS_GetPendingException(cx(), aVal)) {
      return false;
    }
    JS_ClearPendingException(cx());
    return true;
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:12,代码来源:ScriptSettings.cpp


示例14: jsd_GetException

JSDValue*
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
    JSContext* cx;
    jsval val;

    if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
        return NULL;

    if(JS_GetPendingException(cx, &val))
        return jsd_NewValue(jsdc, val);
    return NULL;
}        
开发者ID:lofter2011,项目名称:Icefox,代码行数:13,代码来源:jsd_stak.c


示例15: ToJSValue

bool
ToJSValue(JSContext* aCx,
          ErrorResult& aArgument,
          JS::MutableHandle<JS::Value> aValue)
{
  MOZ_ASSERT(aArgument.Failed());
  MOZ_ASSERT(!aArgument.IsUncatchableException(),
             "Doesn't make sense to convert uncatchable exception to a JS value!");
  AutoForceSetExceptionOnContext forceExn(aCx);
  DebugOnly<bool> throwResult = aArgument.MaybeSetPendingException(aCx);
  MOZ_ASSERT(throwResult);
  DebugOnly<bool> getPendingResult = JS_GetPendingException(aCx, aValue);
  MOZ_ASSERT(getPendingResult);
  JS_ClearPendingException(aCx);
  return true;
}
开发者ID:GuanWen-Chen,项目名称:gecko-b2g,代码行数:16,代码来源:ToJSValue.cpp


示例16: report_js_error

// callback for JS_SetErrorReporter
static void report_js_error(JSContext* js, const char* message, JSErrorReport* UNUSED(report))
{
  // first we find ourselves
  VALUE self = (VALUE)JS_GetContextPrivate(js);

  // then we find our bridge
  JohnsonContext* context;
  Data_Get_Struct(self, JohnsonContext, context);

  // NOTE: SpiderMonkey REALLY doesn't like being interrupted. If we
  // jump over to Ruby and raise here, segfaults and such ensue.
  // Instead, we store the exception (if any) and the error message
  // on the context. They're dealt with in the if (!ok) block of evaluate().

  strncpy(context->msg, message, MAX_EXCEPTION_MESSAGE_SIZE);
  JS_GetPendingException(context->js, &context->ex);
}
开发者ID:matthewd,项目名称:johnson,代码行数:18,代码来源:context.c


示例17: exn

  ~AutoPACErrorReporter() {
    if (!JS_IsExceptionPending(mCx)) {
      return;
    }
    JS::RootedValue exn(mCx);
    if (!JS_GetPendingException(mCx, &exn)) {
      return;
    }
    JS_ClearPendingException(mCx);

    js::ErrorReport report(mCx);
    if (!report.init(mCx, exn, js::ErrorReport::WithSideEffects)) {
      JS_ClearPendingException(mCx);
      return;
    }

    PACLogErrorOrWarning(NS_LITERAL_STRING("Error"), report.report());
  }
开发者ID:cclauss,项目名称:gecko-dev,代码行数:18,代码来源:ProxyAutoConfig.cpp


示例18: try_to_chain_stack_trace

static void
try_to_chain_stack_trace(JSContext *src_context, JSContext *dst_context,
                         jsval src_exc) {
    /* append current stack of dst_context to stack trace for src_exc.
     * we bail if anything goes wrong, just using the src_exc unmodified
     * in that case. */
    jsval chained, src_stack, dst_stack, new_stack;
    JSString *new_stack_str;

    JS_BeginRequest(src_context);
    JS_BeginRequest(dst_context);

    if (!JSVAL_IS_OBJECT(src_exc))
        goto out; // src_exc doesn't have a stack trace

    /* create a new exception in dst_context to get a stack trace */
    gjs_throw_literal(dst_context, "Chained exception");
    if (!(JS_GetPendingException(dst_context, &chained) &&
          JSVAL_IS_OBJECT(chained)))
        goto out; // gjs_throw_literal didn't work?!
    JS_ClearPendingException(dst_context);

    /* get stack trace for src_exc and chained */
    if (!(gjs_object_get_property(dst_context, JSVAL_TO_OBJECT(chained),
                                  "stack", &dst_stack) &&
          JSVAL_IS_STRING(dst_stack)))
        goto out; // couldn't get chained stack
    if (!(gjs_object_get_property(src_context, JSVAL_TO_OBJECT(src_exc),
                                  "stack", &src_stack) &&
          JSVAL_IS_STRING(src_stack)))
        goto out; // couldn't get source stack

    /* add chained exception's stack trace to src_exc */
    new_stack_str = JS_ConcatStrings
        (dst_context, JSVAL_TO_STRING(src_stack), JSVAL_TO_STRING(dst_stack));
    if (new_stack_str==NULL)
        goto out; // couldn't concatenate src and dst stacks?!
    new_stack = STRING_TO_JSVAL(new_stack_str);
    JS_SetProperty(dst_context, JSVAL_TO_OBJECT(src_exc), "stack", &new_stack);

 out:
    JS_EndRequest(dst_context);
    JS_EndRequest(src_context);
}
开发者ID:sjokkis,项目名称:gjs,代码行数:44,代码来源:jsapi-util.c


示例19: AssertIsOnOwningThread

already_AddRefed<IDBTransaction>
IDBDatabase::Transaction(const StringOrStringSequence& aStoreNames,
                         IDBTransactionMode aMode,
                         ErrorResult& aRv)
{
  AssertIsOnOwningThread();

  aRv.MightThrowJSException();

  if (aMode == IDBTransactionMode::Readwriteflush &&
      !IndexedDatabaseManager::ExperimentalFeaturesEnabled()) {
    // Pretend that this mode doesn't exist. We don't have a way to annotate
    // certain enum values as depending on preferences so we just duplicate the
    // normal exception generation here.
    ThreadsafeAutoJSContext cx;

    // Disable any automatic error reporting that might be set up so that we
    // can grab the exception object.
    AutoForceSetExceptionOnContext forceExn(cx);

    MOZ_ALWAYS_FALSE(
      ThrowErrorMessage(cx,
                        MSG_INVALID_ENUM_VALUE,
                        "Argument 2 of IDBDatabase.transaction",
                        "readwriteflush",
                        "IDBTransactionMode"));
    MOZ_ASSERT(JS_IsExceptionPending(cx));

    JS::Rooted<JS::Value> exception(cx);
    MOZ_ALWAYS_TRUE(JS_GetPendingException(cx, &exception));

    aRv.ThrowJSException(cx, exception);
    return nullptr;
  }

  RefPtr<IDBTransaction> transaction;
  aRv = Transaction(aStoreNames, aMode, getter_AddRefs(transaction));
  if (NS_WARN_IF(aRv.Failed())) {
    return nullptr;
  }

  return transaction.forget();
}
开发者ID:70599,项目名称:Waterfox,代码行数:43,代码来源:IDBDatabase.cpp


示例20: excn

bool MozJSImplScope::_checkErrorState(bool success, bool reportError, bool assertOnError) {
    if (success)
        return false;

    if (_quickExit)
        return false;

    if (_status.isOK()) {
        JS::RootedValue excn(_context);
        if (JS_GetPendingException(_context, &excn) && excn.isObject()) {
            str::stream ss;

            JS::RootedValue stack(_context);

            ObjectWrapper(_context, excn).getValue("stack", &stack);

            ss << ValueWriter(_context, excn).toString() << " :\n"
               << ValueWriter(_context, stack).toString();
            _status = Status(ErrorCodes::JSInterpreterFailure, ss);
        } else {
            _status = Status(ErrorCodes::UnknownError, "Unknown Failure from JSInterpreter");
        }
    }

    _error = _status.reason();

    if (reportError)
        error() << _error << std::endl;

    // Clear the status state
    auto status = std::move(_status);

    if (assertOnError) {
        // Throw if necessary
        uassertStatusOK(status);
    }

    return true;
}
开发者ID:Jaryli,项目名称:mongo,代码行数:39,代码来源:implscope.cpp



注:本文中的JS_GetPendingException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JS_GetProperty函数代码示例发布时间:2022-05-30
下一篇:
C++ JS_GetInstancePrivate函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap