chaijs/chai — pull request #133 by RubenVerborgh (2013-01-27 19:25:08+00:00)
Title: Fix assertions on functions that throw primitives

Although [not recommended](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/), JavaScript functions [can throw anything](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/throw#Description), *i.e.,* not necessarily an `Error`.

However, Chai does not nicely deal with them. Consider the following snippet of code:

```JavaScript
(function () { throw "test"; }).should.throw("test");
(function () { throw "test"; }).should.throw("whatever");
(function () { throw "test"; }).should.not.throw("whatever");
```

Currently, line 2 incorrectly doesn't cause an error, but line 3 does:

```
expected [Function] to not throw an error but 'test' was thrown
```

This pull request adds support for primitive errors, correctly resulting in this error for line 2:

```
expected [Function] to throw error including 'whatever' but got 'test'
```