main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
691 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | var formatter = require('format')
|
---|
| 4 |
|
---|
| 5 | var fault = create(Error)
|
---|
| 6 |
|
---|
| 7 | module.exports = fault
|
---|
| 8 |
|
---|
| 9 | fault.eval = create(EvalError)
|
---|
| 10 | fault.range = create(RangeError)
|
---|
| 11 | fault.reference = create(ReferenceError)
|
---|
| 12 | fault.syntax = create(SyntaxError)
|
---|
| 13 | fault.type = create(TypeError)
|
---|
| 14 | fault.uri = create(URIError)
|
---|
| 15 |
|
---|
| 16 | fault.create = create
|
---|
| 17 |
|
---|
| 18 | // Create a new `EConstructor`, with the formatted `format` as a first argument.
|
---|
| 19 | function 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.