mozilla-b2g/sockit-to-me — pull request #3 by jugglinmike (2013-07-20 01:07:43+00:00)
Title: Throw errors

I've been using this module a bit, and I found the following behavior to be somewhat surprising:

```javascript
var sockittome = require('./');
var sockit = new sockittome.Sockit();
sockit.read(1); // fails "silently"
var err = socket.read(1);
if (err) {
console.error("Error!", err);
}
```

Usually, Error objects are passed around as values in asynchronous API's (like Node.js's callback-driven API). Since this API is completely synchronous, it's more intuitive to use JavaScript's native Error raising mechanism. This enables more idiomatic usage like:

```javascript
var sockittome = require('./');
var sockit = new sockittome.Sockit();
try {
sockit.read(1); // fails "silently"
} catch(err) {
console.error("Error!", err);
}
```

What do you think?