3 ms·
if(x) throw x
by z3t4 8y ago
if(x) throw x
- Normal_gaussian 8y agoThe reason this doesn't work in the same way is because it requires you to know where the error occurs. You tend to operate on a data structure and know that at some point x becomes y. By placing a watch on x you find out where that point is. Editing the code does not get you this (bar modern proxies in js).
- plausibilities 8y agoif(x) { debugger }
- Normal_gaussian 8y agoPlay with conditional watchpoints in gdb to understand why this does not make sense as a reply to the comment explaining why this is not a substitute.
- z3t4 8y agoAha. I sometimes use ES5 defineProperty where you can define get and set functions. I built an ORM using defineProperty. Where changing a value triggers an database update. But the best way is to avoid globals or only update it at one place.