[LCEngineFunction("asyncException")]
        public static async Task<string> AsyncException()
        {
            await Task.Delay(500);
            throw new LCException(400, "error message");
            //返回结果 Exception of type 'LeanCloud.LCException' was thrown.
        }

在.Net 异步云函数中, Throw LCException 后会响应 Exception of type 'LeanCloud.LCException' was thrown.
但在同步云函数中,则会返回 JSON Object {"code":400,"message":"error message"}

如果希望在异步云函数中,也同样返回JSON Object,应该要怎样做?

目前我的做法是手动在每个云函数中将LCException转换成一般的Excetion(Message设成JSON Object), 但这个不是正确方法对吧

        [LCEngineFunction("asyncExceptionFixed")]
        public static async Task<string> AsyncExceptionFixed()
        {
            try
            {
                await Task.Delay(500);
                throw new LCException(400, "error message");
            }
            catch (LCException e)
            {
                throw new Exception(JsonConvert.SerializeObject(new { code = e.Code, message = e.Message }));
                //返回结果 {"code":400,"message":"error message"}
            }
        }

不论是同步或异步云函数,只要抛异常,客户端都会收到响应的 LCException。
如果抛出 LCException,云引擎将会返回 {"code":${lcEx.Code}, "message":${lcEx.Message}},其中 lcEx 为云函数抛出的 LCException 对象;
如果抛出一般的 Exception,云引擎将会返回 {"code":1, "message":${ex.Message}},其中 ex 为云函数抛出的 Exception 对象。

用REST API 测试了一下,好像是会有这个问题?
创建了个测试应用(国际版、名称 Playground_dotNet、AppId kqcxqObfiKTezRiuH7fNvLQP-MdYXbMMI
下面是对应的Request

REQUEST
curl --location --request POST 'https://kqcxqObf.api.lncldglobal.com/1.1/functions/asyncException' --header 'X-LC-Id: kqcxqObfiKTezRiuH7fNvLQP-MdYXbMMI' --header 'X-LC-Key: bIRO8wkXCu6u4o20jEYz1T5W' --header 'Content-Type: application/json' --data-raw '{}'

RESPONSE
Exception of type 'LeanCloud.LCException' was thrown.

云函数长这样

        [LCEngineFunction("asyncException")]
        public static async Task<string> AsyncException()
        {
            await Task.Delay(500);
            throw new LCException(400, "error message");
            //Result: Exception of type 'LeanCloud.LCException' was thrown.
        }

请确认云引擎 SDK 版本在 0.9.112 以上

更新后没问题了 谢谢