is-recoverable-error
v1.0.3
Published
isRecoverableError from Node.js' REPL
Downloads
262,402
Keywords
Readme
is-recoverable-error
isRecoverableError function from Node.js REPL
Usage
var isRecoverableError = require('is-recoverable-error')
var repl = require('repl')
var vm = require('vm')
function myEval (input, context, filename, callback) {
var result
try {
result = vm.runInThisContext(input)
} catch (e) {
if (isRecoverableError(input)) {
return callback(new repl.Recoverable(e))
}
}
callback(null, result)
}
API
isRecoverableError(input)
Where input is a string. Returns a boolean.
isRecoverableError('function x () {') // returns true
isRecoverableErorr('<cat>') // returns false
Installation
npm install -S is-recoverable-error
License
MIT