Add error support to js
Tweak promotion logic.