Comparing version 9.1.0 to 9.1.1
@@ -72,5 +72,20 @@ /** | ||
// ensure `_data` exists and is an Error instance | ||
if (_.isError(_data)) { | ||
// TODO: if this error came from a machine internal to the implementation of THIS machine, add something to the error message+stack about that. | ||
err = _data; | ||
} | ||
// (if not, build it as an error object using the exit definition) | ||
if (!_.isError(_data)) { | ||
err = new Error(util.format('`%s` triggered its `%s` exit', self.identity, exitName) + ((self.exits[exitName] && self.exits[exitName].description)?': '+self.exits[exitName].description:'') + ''); | ||
else { | ||
var exitDef = self.exits[exitName]; | ||
var exitDescription = exitDef && exitDef.description; | ||
var exitHasOutput = exitDef && !_.isUndefined(exitDef.example); | ||
var errMsg = util.format( | ||
'`%s` triggered its `%s` exit.\n%s%s', | ||
self.identity, | ||
exitName, | ||
(exitDescription ? ('\nDescription:\n'+exitDescription+'\n') : ''), | ||
(exitHasOutput ? ('\nOutput:\n'+util.inspect(_data, false, null)+'\n') : '') | ||
); | ||
err = new Error(errMsg); | ||
// TODO: use a nice module to trim some of the crap from `machine` itself off of the stack. | ||
err.code = exitName; | ||
@@ -80,5 +95,2 @@ err.exit = exitName; | ||
} | ||
else { | ||
err = _data; | ||
} | ||
}; | ||
@@ -92,2 +104,3 @@ }); | ||
var _err = new Error('Cannot use `.execSync()` with `'+identity+'` machine because, although it declares synchronous usage (i.e. `sync:true`), it is not actually synchronous.'); | ||
// TODO: use a nice module to trim some of the crap from `machine` itself off of the stack. | ||
_err.code = 'E_MACHINE_INCONSISTENT'; | ||
@@ -107,5 +120,12 @@ return _err; | ||
if (err) { | ||
if (typeof err === 'object' && err instanceof Error) throw err; | ||
if (typeof err === 'string') throw new Error(err); | ||
throw new Error(util.inspect(err, false, null)); | ||
if (_.isError(err)) { | ||
throw err; | ||
} | ||
if (_.isString(err)) { | ||
err = new Error(err); | ||
} | ||
err = new Error(util.inspect(err, false, null)); | ||
// TODO: use a nice module to trim some of the crap from `machine` itself off of the stack. | ||
throw err; | ||
} | ||
@@ -112,0 +132,0 @@ |
{ | ||
"name": "machine", | ||
"version": "9.1.0", | ||
"version": "9.1.1", | ||
"description": "Configure and execute machines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85245
1933