Unity Firebase函数.https.onRequest调用错误始终是内部错误消息:响应无效的JSON对象

时间:2019-02-26 13:09:30

标签: firebase unity3d google-cloud-functions

我正在尝试在Unity中处理Firebase云功能错误,但是我无法始终收到错误代码为“内部”和错误消息“响应无效的JSON对象”的错误。

在阅读了Firebase文档和其他一些堆栈溢出问题之后,我了解到function.https.onCall和functions.https.onRequest之间是有区别的。我们目前正在使用onRequest,因为除了Android和iOS,我们还需要从网络访问这些功能。

有问题的云代码:

    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX schema: <http://schema.org/>
    PREFIX wikibase: <http://wikiba.se/ontology#>
    PREFIX wd: <http://www.wikidata.org/entity/>
    PREFIX wdt: <http://www.wikidata.org/prop/direct/>

    SELECT DISTINCT  * 

    WHERE {
      ?item rdfs:label "Karlsruhe"@de.   

      ?item rdfs:label ?label_de.
      FILTER((LANG(?label_de)) = "de").

      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], de, en, fr". }

        bind(if(exists{?item wdt:P17 []}, "yes", "no") as ?country_)

      optional {

          ?item rdfs:label ?label_en.     
          FILTER((LANG(?label_en)) = "en").      
          ?item rdfs:label ?label_fr.  
          FILTER((LANG(?label_fr)) = "fr").

        ?item skos:altLabel ?altLabel_de.
        FILTER(LANGMATCHES(LANG(?altLabel_de), "de"))

        optional {
        ?item skos:altLabel ?altLabel_en.
        FILTER(LANGMATCHES(LANG(?altLabel_en), "en"))
          }

        optional {
        ?item skos:altLabel ?altLabel_fr.
        FILTER(LANGMATCHES(LANG(?altLabel_fr), "fr"))
          }
      }  
    } 
    order by ?item

统一代码:

app.post("/test", (req, res) => {
    res.status(500).send("This message will never appear in the editor");
});

exports.app = functions.https.onRequest(app);

exports.ThisTestWorks = functions.https.onCall((data, context) => {
    throw new functions.https.HttpsError('invalid-argument', 'This message will appear in the editor');
});

此代码将返回以下日志:

FirebaseProcess retVal = new FirebaseProcess();
FunctionInst.GetHttpsCallable("app/test").CallAsync(request).ContinueWith(t => {
    if (t.IsFaulted || t.IsCanceled) {
        foreach (var inner in t.Exception.InnerExceptions) {
            if (inner is FunctionsException) {
                var e = (FunctionsException) inner;
                Debug.Log("e.ErrorCode: " + e.ErrorCode + ", e.Message: " + e.Message);
            } else {
                Debug.Log("inner.Message: " + inner.Message);
            }
        }
        Debug.Log("t.Exception.Message " + t.Exception.Message);
        Debug.Log("t.Status " + t.Status);

    } else {
        retVal.Success = true;
        retVal.ResultJSON = t.Result.Data as string;
    }
    retVal.IsRunning = false;
});

完整(相关)云代码:

e.ErrorCode: Internal, e.Message: Response is not valid JSON object.
t.Exception.Message One or more errors occurred.
t.Status Faulted

有没有理由在Unity编辑器中不返回自定义错误?我在这里想念什么?

谢谢!

0 个答案:

没有答案