static function asSurpriseTypedError($err, $msg = null, $p = null)
 {
     if ($msg === null) {
         $msg = "Failure: " . Std::string($err);
     }
     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($err, $msg, $p)));
 }
 public function deleteTemporaryFile()
 {
     try {
         @unlink($this->tmpFileName);
         return tink_core_Outcome::Success(tink_core_Noise::$Noise);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return tink_core_Outcome::Failure(tink_core_TypedError::withData(null, "Error during TmpFileUpload.deleteTmpFile()", $e, _hx_anonymous(array("fileName" => "TmpFileUpload.hx", "lineNumber" => 165, "className" => "ufront.web.upload.TmpFileUpload", "methodName" => "deleteTemporaryFile"))));
     }
 }
 static function catchExceptions($f, $report = null)
 {
     try {
         return tink_core_Outcome::Success(call_user_func($f));
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         if (($e = $_ex_) instanceof tink_core_TypedError) {
             return tink_core_Outcome::Failure($e);
         } else {
             $e1 = $_ex_;
             return tink_core_Outcome::Failure($report === null ? tink_core_TypedError::withData(null, "Unexpected Error", $e1, _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 97, "className" => "tink.core.TypedError", "methodName" => "catchExceptions"))) : call_user_func_array($report, array($e1)));
         }
     }
 }
 public function executeResult($context)
 {
     try {
         return $context->actionContext->actionResult->executeResult($context->actionContext);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         $p_methodName = "executeResult";
         $p_lineNumber = -1;
         $p_fileName = "";
         $p_customParams = new _hx_array(array("actionContext"));
         $p_className = Type::getClassName(Type::getClass($context->actionContext));
         return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::wrap($e, null, _hx_anonymous(array("fileName" => "MVCHandler.hx", "lineNumber" => 70, "className" => "ufront.web.MVCHandler", "methodName" => "executeResult")))));
     }
 }
function tink_core__Outcome_OutcomeMapper_Impl__1(&$f, $o)
{
    switch ($o->index) {
        case 0:
            $d = _hx_deref($o)->params[0];
            $_g = call_user_func_array($f, array($d));
            switch ($_g->index) {
                case 0:
                    $d1 = _hx_deref($_g)->params[0];
                    return tink_core_Outcome::Success($d1);
                    break;
                case 1:
                    $f1 = _hx_deref($_g)->params[0];
                    return tink_core_Outcome::Failure(tink_core_Either::Right($f1));
                    break;
            }
            break;
        case 1:
            $f2 = _hx_deref($o)->params[0];
            return tink_core_Outcome::Failure(tink_core_Either::Left($f2));
            break;
    }
}
function sys_ufront_web_context_HttpRequest_7(&$_g, &$callbackFutures, &$currentContent, &$doData, &$doEndOfPart, &$doPart, &$e, &$errors, &$fileName, &$isFile, &$noParts, &$onData, &$onEndPart, &$onPart, &$partName, &$processCallbackResult, $_5)
{
    if ($errors->length === 0) {
        $data3 = tink_core_Outcome::Success(tink_core_Noise::$Noise);
        return tink_core__Future_Future_Impl_::sync($data3);
    } else {
        $data4 = tink_core_Outcome::Failure(tink_core_TypedError::withData(null, "Error parsing multipart request data", $errors, _hx_anonymous(array("fileName" => "HttpRequest.hx", "lineNumber" => 174, "className" => "sys.ufront.web.context.HttpRequest", "methodName" => "parseMultipart"))));
        return tink_core__Future_Future_Impl_::sync($data4);
    }
}
 public function execute()
 {
     if (!php_Boot::$skip_constructor) {
         return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::internalServerError("Field execute() in ufront.web.Controller is an abstract method, please override it in " . _hx_string_or_null($this->toString()) . " ", null, _hx_anonymous(array("fileName" => "Controller.hx", "lineNumber" => 206, "className" => "ufront.web.Controller", "methodName" => "execute")))));
     }
 }
 static function attempt($f, $report)
 {
     try {
         return tink_core_Outcome::Success(call_user_func($f));
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return tink_core_Outcome::Failure(call_user_func_array($report, array($e)));
     }
 }
 public function handleError($err, $ctx, $doneTrigger)
 {
     $_g = $this;
     if (!(($ctx->completion & 1 << ufront_web_context_RequestCompletion::$CErrorHandlersTriggered->index) !== 0)) {
         $ctx->completion |= 1 << ufront_web_context_RequestCompletion::$CErrorHandlersTriggered->index;
         $errHandlerModules = $this->errorHandlers->map(array(new _hx_lambda(array(&$_g, &$ctx, &$doneTrigger, &$err), "ufront_app_HttpApplication_10"), 'execute'));
         $resMidModules = $this->responseMiddleware->map(array(new _hx_lambda(array(&$_g, &$ctx, &$doneTrigger, &$err, &$errHandlerModules), "ufront_app_HttpApplication_11"), 'execute'));
         $logHandModules = $this->logHandlers->map(array(new _hx_lambda(array(&$_g, &$ctx, &$doneTrigger, &$err, &$errHandlerModules, &$resMidModules), "ufront_app_HttpApplication_12"), 'execute'));
         $allDone = tink_core__Future_Future_Impl_::_tryFailingFlatMap(tink_core__Future_Future_Impl_::_tryFailingFlatMap($this->executeModules($errHandlerModules, $ctx, ufront_web_context_RequestCompletion::$CErrorHandlersComplete), array(new _hx_lambda(array(&$_g, &$ctx, &$doneTrigger, &$err, &$errHandlerModules, &$logHandModules, &$resMidModules), "ufront_app_HttpApplication_13"), 'execute')), array(new _hx_lambda(array(&$_g, &$ctx, &$doneTrigger, &$err, &$errHandlerModules, &$logHandModules, &$resMidModules), "ufront_app_HttpApplication_14"), 'execute'));
         $callback = null;
         $f3 = null;
         $f4 = isset($doneTrigger->trigger) ? $doneTrigger->trigger : array($doneTrigger, "trigger");
         $a13 = tink_core_Outcome::Failure($err);
         $f3 = array(new _hx_lambda(array(&$_g, &$a13, &$allDone, &$callback, &$ctx, &$doneTrigger, &$err, &$errHandlerModules, &$f3, &$f4, &$logHandModules, &$resMidModules), "ufront_app_HttpApplication_15"), 'execute');
         $callback = array(new _hx_lambda(array(&$_g, &$allDone, &$callback, &$ctx, &$doneTrigger, &$err, &$errHandlerModules, &$f3, &$logHandModules, &$resMidModules), "ufront_app_HttpApplication_16"), 'execute');
         $allDone($callback);
     } else {
         $msg = "You had an error after your error handler had already run.  Last active module: " . _hx_string_or_null($this->currentModule->className) . "." . _hx_string_or_null($this->currentModule->methodName);
         Sys::println($msg);
         Sys::println("Error Data: " . Std::string($err->data));
         $err->throwSelf();
     }
 }
 public function _makeApiCall($method, $args, $flags, $pos = null)
 {
     if (!php_Boot::$skip_constructor) {
         $_g = $this;
         $remotingCallString = "" . _hx_string_or_null($this->className) . "." . _hx_string_or_null($method) . "(" . _hx_string_or_null($args->join(",")) . ")";
         $callApi = array(new _hx_lambda(array(&$_g, &$args, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_0"), 'execute');
         $returnError = array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_1"), 'execute');
         if (($flags & 1 << ufront_api_ApiReturnType::$ARTVoid->index) !== 0) {
             try {
                 call_user_func($callApi);
                 return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(null));
             } catch (Exception $__hx__e) {
                 $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                 $e1 = $_ex_;
                 return call_user_func_array($returnError, array($e1));
             }
         } else {
             if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0 && ($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) {
                 try {
                     $surprise = call_user_func($callApi);
                     return tink_core__Future_Future_Impl_::map($surprise, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString, &$returnError, &$surprise), "ufront_api_UFAsyncApi_2"), 'execute'), null);
                 } catch (Exception $__hx__e) {
                     $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                     $e2 = $_ex_;
                     return call_user_func_array($returnError, array($e2));
                 }
             } else {
                 if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0) {
                     try {
                         $future = call_user_func($callApi);
                         return tink_core__Future_Future_Impl_::map($future, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$future, &$method, &$pos, &$remotingCallString, &$returnError), "ufront_api_UFAsyncApi_3"), 'execute'), null);
                     } catch (Exception $__hx__e) {
                         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                         $e3 = $_ex_;
                         return call_user_func_array($returnError, array($e3));
                     }
                 } else {
                     if (($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) {
                         try {
                             $outcome = call_user_func($callApi);
                             switch ($outcome->index) {
                                 case 0:
                                     $data2 = _hx_deref($outcome)->params[0];
                                     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($data2));
                                     break;
                                 case 1:
                                     $err1 = _hx_deref($outcome)->params[0];
                                     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::remotingError(ufront_remoting_RemotingError::RApiFailure($remotingCallString, $err1), $pos)));
                                     break;
                             }
                         } catch (Exception $__hx__e) {
                             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                             $e4 = $_ex_;
                             return call_user_func_array($returnError, array($e4));
                         }
                     } else {
                         try {
                             $result1 = call_user_func($callApi);
                             return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($result1));
                         } catch (Exception $__hx__e) {
                             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                             $e5 = $_ex_;
                             return call_user_func_array($returnError, array($e5));
                         }
                     }
                 }
             }
         }
     }
 }
function ufront_core_CallbackTools_2(&$cb, &$pos, &$t, $error, $val1, $val2)
{
    if ($error !== null) {
        $e = tink_core_TypedError::withData(500, "" . Std::string($error), $pos, _hx_anonymous(array("fileName" => "AsyncTools.hx", "lineNumber" => 266, "className" => "ufront.core.CallbackTools", "methodName" => "asSurprisePair")));
        $result = tink_core_Outcome::Failure($e);
        if ($t->{"list"} === null) {
            false;
        } else {
            $list = $t->{"list"};
            $t->{"list"} = null;
            $t->result = $result;
            tink_core__Callback_CallbackList_Impl_::invoke($list, $result);
            tink_core__Callback_CallbackList_Impl_::clear($list);
            true;
        }
    } else {
        $result1 = tink_core_Outcome::Success(new tink_core_MPair($val1, $val2));
        if ($t->{"list"} === null) {
            false;
        } else {
            $list1 = $t->{"list"};
            $t->{"list"} = null;
            $t->result = $result1;
            tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1);
            tink_core__Callback_CallbackList_Impl_::clear($list1);
            true;
        }
    }
}
function ufront_web_upload_TmpFileUploadMiddleware_3(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onEndPart, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath, $result)
{
    switch ($result->index) {
        case 0:
            $s = _hx_deref($result)->params[0];
            return tink_core_Outcome::Success($s);
            break;
        case 1:
            $f = _hx_deref($result)->params[0];
            return tink_core_Outcome::Failure(ufront_web_HttpError::wrap($f, null, _hx_anonymous(array("fileName" => "TmpFileUploadMiddleware.hx", "lineNumber" => 101, "className" => "ufront.web.upload.TmpFileUploadMiddleware", "methodName" => "requestIn"))));
            break;
    }
}
function tink_core__Future_Future_Impl__13(&$f, &$map, $o)
{
    switch ($o->index) {
        case 0:
            $a = _hx_deref($o)->params[0];
            return tink_core_Outcome::Success(call_user_func_array($map, array($a)));
            break;
        case 1:
            $f1 = _hx_deref($o)->params[0];
            return tink_core_Outcome::Failure($f1);
            break;
    }
}
 public function getTemplateString($path)
 {
     return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(new tink_core_TypedError(null, "Attempting to fetch template " . _hx_string_or_null($path) . " with UFViewEngine.  This is an abstract class, you must use one of the ViewEngine implementations.", _hx_anonymous(array("fileName" => "UFViewEngine.hx", "lineNumber" => 208, "className" => "ufront.view.UFViewEngine", "methodName" => "getTemplateString")))));
 }