asadm / playroom-unity

9 stars 1 forks source link

Errors piping to c# #38

Closed asadm closed 4 months ago

asadm commented 5 months ago

I noticed that if Unity calls some native javascript code, and that throws an error, the error doesn't propagate automatically in my C# code, so I can't wrap my own code in some try catch. How do you guys deal with this situation?

image

momintlh commented 5 months ago

What should I do here, catch the errors on JS side and send to unity?

SaadBazaz commented 5 months ago

What should I do here, catch the errors on JS side and send to unity?

That sounds reasonable. Essentially it might be cool to differentiate between a Unity error and a JavaScript error. So an interesting idea would be to throw an Error in C# with

{
    "type": "UNCAUGHT_JAVASCRIPT_EXCEPTION",
    "message": "Uncaught exception in JavaScript library",
    "error": "<dump everything here/>"
}
SaadBazaz commented 4 months ago

Shifted to #40 for further discussion, as the OP's Issue has been solved.