dimforge / rapier.js

Official JavaScript bindings for the Rapier physics engine.
https://rapier.rs
Apache License 2.0
418 stars 57 forks source link

JS bindings: silent errors in callbacks #253

Open codefrau opened 1 year ago

codefrau commented 1 year ago

The handleError() function in rapier_wasm3d_bg.js eats all errors silently, e.g.

world.forEachRigidBody(rb => { throw Error("foo"); })

That makes it hard to debug. An easy fix would be adding a console.error() line like

function handleError(f, args) {
    try {
        return f.apply(this, args);
    } catch (e) {
        console.error(e);
        wasm.__wbindgen_exn_store(addHeapObject(e));
    }
}

I could not find handleError() in this repo, otherwise I'd have submitted a pull request.