function ufront_api_UFAsyncApi_1(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString, $e)
{
    $stack = haxe_CallStack::toString(haxe_CallStack::exceptionStack());
    $remotingError = ufront_remoting_RemotingError::RServerSideException($remotingCallString, $e, $stack);
    return ufront_core_SurpriseTools::asBadSurprise(ufront_web_HttpError::remotingError($remotingError, $pos));
}
 static function processResponse($response, $onResult, $errorHandler, $remotingCallString)
 {
     $ret = null;
     $stack = null;
     $hxrFound = false;
     $errors = new _hx_array(array());
     $onError = ufront_remoting_RemotingUtil::wrapErrorHandler($errorHandler);
     if (_hx_substr($response, 0, 2) !== "hx") {
         call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response)));
     } else {
         $_g = 0;
         $_g1 = _hx_explode("\n", $response);
         while ($_g < $_g1->length) {
             $line = $_g1[$_g];
             ++$_g;
             if ($line === "") {
                 continue;
             }
             $_g2 = _hx_substr($line, 0, 3);
             switch ($_g2) {
                 case "hxr":
                     $s = new haxe_Unserializer(_hx_substr($line, 3, null));
                     try {
                         $ret = $s->unserialize();
                     } catch (Exception $__hx__e) {
                         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                         $e = $_ex_;
                         $ret = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e)));
                     }
                     $hxrFound = true;
                     break;
                 case "hxt":
                     $s1 = new haxe_Unserializer(_hx_substr($line, 3, null));
                     $m = null;
                     try {
                         $m = $s1->unserialize();
                     } catch (Exception $__hx__e) {
                         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                         $e1 = $_ex_;
                         $m = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e1)));
                     }
                     $m->pos->fileName = "[R]" . _hx_string_or_null($m->pos->fileName);
                     haxe_Log::trace("[" . Std::string($m->type) . "]" . Std::string($m->msg), $m->pos);
                     break;
                 case "hxs":
                     $s2 = new haxe_Unserializer(_hx_substr($line, 3, null));
                     try {
                         $stack = $s2->unserialize();
                     } catch (Exception $__hx__e) {
                         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                         $e2 = $_ex_;
                         $stack = $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, _hx_substr($line, 3, null), "" . Std::string($e2)));
                     }
                     break;
                 case "hxe":
                     $s3 = new haxe_Unserializer(_hx_substr($line, 3, null));
                     try {
                         $ret = $s3->unserialize();
                     } catch (Exception $__hx__e) {
                         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                         $e3 = $_ex_;
                         $ret = $errors->push(ufront_remoting_RemotingError::RServerSideException($remotingCallString, $e3, $stack));
                     }
                     break;
                 default:
                     $errors->push(ufront_remoting_RemotingError::RUnserializeFailed($remotingCallString, $line, "Invalid line in response"));
                     break;
             }
             unset($_g2);
             unset($line);
         }
     }
     if ($errors->length === 0) {
         if ($hxrFound) {
             try {
                 call_user_func_array($onResult, array($ret));
             } catch (Exception $__hx__e) {
                 $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                 $e4 = $_ex_;
                 call_user_func_array($onError, array(ufront_remoting_RemotingError::RClientCallbackException($remotingCallString, $e4)));
             }
         } else {
             call_user_func_array($onError, array(ufront_remoting_RemotingError::RNoRemotingResult($remotingCallString, $response)));
         }
     } else {
         $_g3 = 0;
         while ($_g3 < $errors->length) {
             $err = $errors[$_g3];
             ++$_g3;
             call_user_func_array($onError, array($err));
             unset($err);
         }
     }
 }