Code Monkey home page Code Monkey logo

Comments (7)

chexiongsheng avatar chexiongsheng commented on July 22, 2024 6

也对,我加下unhandledRejection的支持

from puerts.

chexiongsheng avatar chexiongsheng commented on July 22, 2024

“将js方法注册为button的点击事件”,这个会变成c#异常啊。不会看不到报错。
“j某个异步方法内抛出异常”,这个看js的文档,可以catch,demo也有例子。

from puerts.

wchrt avatar wchrt commented on July 22, 2024

很多业务开发不会去主动写catch的, 例如有个async func(){ throw new Error(); } 业务上就调用了了 func(); 没有去await也没有去.catch(). 就算上层有try或.catch(), 也不会拿到这个异常的嘛, 这样这个异常就没地方可捕获. 浏览器可以通过全局的error事件捕获到这个异常, nodejs可以通过uncaughtException捕获到

from puerts.

wchrt avatar wchrt commented on July 22, 2024

将js方法注册为button的点击事件, 如果注册的是一个async方法, 那么是不会变为C#异常的, 看不到报错. 注册同步方法是没问题的.
这问题和上面的一样, 异步执行的方法没有主动捕获就拿不到异常.

from puerts.

chexiongsheng avatar chexiongsheng commented on July 22, 2024

那归根到底还是异步方法的异常。
异步方法必须这样catch,这是js的规范,我不可能改这点的,只能你们去适应了。

from puerts.

wchrt avatar wchrt commented on July 22, 2024

在浏览器和nodejs上, 都能拿到没有catch的异常呢.
说真的, 业务开发要按照规范编写catch非常痛苦, 很多场景都是不关心异常, 但出现异常又能被知晓

from puerts.

chexiongsheng avatar chexiongsheng commented on July 22, 2024

支持unhandledRejection了,使用上可以先参考ut用例:https://github.com/Tencent/puerts/blob/master/unity/general/Src/UnitTest/UnitTest.cs#L951

from puerts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.