Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 168e8b5

Browse files
committed
refactor: use es6 class syntax for CommandError
This is supposed to be a NOOP, although for some reason this makes a difference in the ava@6 test framework. This should not have a user-visible effect because CommandError is an implementation detail of this library (it's only thrown if `options.fatal` is off, and it's always caught inside of common.js).
1 parent 697bcf6 commit 168e8b5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/common.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ exports.convertErrorOutput = convertErrorOutput;
8383

8484
// An exception class to help propagate command errors (e.g., non-zero exit
8585
// status) up to the top-level. {@param value} should be a ShellString.
86-
function CommandError(value) {
87-
this.returnValue = value;
86+
class CommandError extends Error {
87+
constructor(value) {
88+
super(value.toString());
89+
this.returnValue = value;
90+
}
8891
}
89-
CommandError.prototype = Object.create(Error.prototype);
90-
CommandError.prototype.constructor = CommandError;
9192
exports.CommandError = CommandError; // visible for testing
9293

9394
// Shows error message. Throws if fatal is true (defaults to config.fatal, overridable with options.fatal)

0 commit comments

Comments
 (0)