Exemple #1
0
        public static Future sync(Func <FutureOr> computation)
        {
            try {
                var result = computation();
                if (result.isFuture)
                {
                    return(result.f);
                }
                else
                {
                    return(_Future.value(result));
                }
            }
            catch (Exception error) {
                var        future      = new _Future();
                AsyncError replacement = Zone.current.errorCallback(error);
                if (replacement != null)
                {
                    future._asyncCompleteError(async_._nonNullError(replacement.InnerException));
                }
                else
                {
                    future._asyncCompleteError(error);
                }

                return(future);
            }
        }
Exemple #2
0
        internal static _Future immediateError(Exception error)
        {
            var future = new _Future(Zone.current);

            future._asyncCompleteError(error);
            return(future);
        }
Exemple #3
0
        internal static void _asyncCompleteWithErrorCallback(_Future result, Exception error)
        {
            AsyncError replacement = Zone.current.errorCallback(error);

            if (replacement != null)
            {
                error = _nonNullError(replacement.InnerException);
            }

            result._asyncCompleteError(error);
        }