source: node_modules/fault/index.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 691 bytes
Line 
1'use strict'
2
3var formatter = require('format')
4
5var fault = create(Error)
6
7module.exports = fault
8
9fault.eval = create(EvalError)
10fault.range = create(RangeError)
11fault.reference = create(ReferenceError)
12fault.syntax = create(SyntaxError)
13fault.type = create(TypeError)
14fault.uri = create(URIError)
15
16fault.create = create
17
18// Create a new `EConstructor`, with the formatted `format` as a first argument.
19function create(EConstructor) {
20 FormattedError.displayName = EConstructor.displayName || EConstructor.name
21
22 return FormattedError
23
24 function FormattedError(format) {
25 if (format) {
26 format = formatter.apply(null, arguments)
27 }
28
29 return new EConstructor(format)
30 }
31}
Note: See TracBrowser for help on using the repository browser.