package.index.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fault Show documentation
Show all versions of fault Show documentation
Functional errors with formatted output
The newest version!
'use strict'
var formatter = require('format')
var fault = create(Error)
module.exports = fault
fault.eval = create(EvalError)
fault.range = create(RangeError)
fault.reference = create(ReferenceError)
fault.syntax = create(SyntaxError)
fault.type = create(TypeError)
fault.uri = create(URIError)
fault.create = create
// Create a new `EConstructor`, with the formatted `format` as a first argument.
function create(EConstructor) {
FormattedError.displayName = EConstructor.displayName || EConstructor.name
return FormattedError
function FormattedError(format) {
if (format) {
format = formatter.apply(null, arguments)
}
return new EConstructor(format)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy