(fn, match)
| 106 | |
| 107 | /* istanbul ignore next */ |
| 108 | function throws (fn, match) { |
| 109 | try { |
| 110 | fn() |
| 111 | assert(false, 'Expecting error') |
| 112 | } catch (error) { |
| 113 | if (!match.test(error)) { |
| 114 | error.message = `Error did not match ${match}\n${error.message}` |
| 115 | throw error |
| 116 | } |
| 117 | } |
| 118 | } |