Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

[Electron Debug] Thrown errors are undefined after System.start() #1239

Closed zshoals closed 2 years ago

zshoals commented 4 years ago

Throwing an error is resulting in "undefined" instead of the stack trace because error.stack is null for some reason at this point on Electron:

https://github.com/Kode/Kha/blob/5e72acda31d454ad214157f3d3a694eb9c5cf083/Backends/HTML5/kha/SystemImpl.hx#L59-L62

This is with Kha and all submodules updated. I am fairly certain everything was working awhile ago but it's been quite a bit since I've thrown an error.

zshoals commented 3 years ago

As an update, I believe this was caused by Haxe 4.1 and its exception changes. I bandaided this locally in the error handler by typing error as a haxe.Exception, which actually seems to work and get the stack trace to print out properly. Problem is that js.lib.Errors can also be thrown (which aren't Exceptions), and I could not get the error handler to handle both those and Exceptions simultaneously. Trying to cast things just resulted in empty stack fields.

Maybe you know how to do it properly, or if you don't care about js.lib.Error then error: haxe.Exception is sufficient here, which probably covers the common case?

RobDangerous commented 3 years ago

Handling both would be cool, I'll have a look.

RblSb commented 2 years ago

Fixed in https://github.com/Kode/Kha/commit/f0370a407a9dda8091921e8698baf23838ed9c55

RobDangerous commented 2 years ago

No, it's not.