joyent/node — Issue #2150: Have C++ assertion failures throw a JS error instead (when exposed to the user)
Author: vicapow
Created: 2011-11-19 23:16:28+00:00
State: open

So with node, sometimes it's possible to write user space code that throws C++ assertion errors. Assertions are great for sanity checks but if user as a type in there code, a C++ user error to them isn't going to have any meaning. the bellow code illustrates this:

```javascript
var crypto = require('crypto');
var decipher = crypto.Decipher();
```
but it throws a C++ assertion error:

Assertion failed: (handle->InternalFieldCount() > 0), function Wrap, file ../src/node_object_wrap.h, line 61.

but the user just forgot the "new" keyboard:
```javascript
var crypto = require('crypto');
var decipher = new crypto.Decipher();
```
A much better mechanism would be an error that points to the line number that caused the problem.