Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Avoid empty error messages #6

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function psc(opts) {
gutil.log('Stderr from \'' + gutil.colors.cyan('psc') + '\'\n' + gutil.colors.magenta(stderr));
});
cmd.on('close', function(code){
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
if (!!code) fail(that, 'psc', buffer);
else {
that.push(new gutil.File({
path: output,
Expand All @@ -116,7 +116,7 @@ function pscMake(opts) {
gutil.log('Stderr from \'' + gutil.colors.cyan('psc-make') + '\'\n' + gutil.colors.magenta(stderr));
});
cmd.on('close', function(code){
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, 'psc-make has failed'));
if (!!code) fail(that, 'psc-make', buffer);
cb();
});
});
Expand All @@ -136,7 +136,7 @@ function docgen(opts) {
gutil.log('Stderr from \'' + gutil.colors.cyan('docgen') + '\'\n' + gutil.colors.magenta(stderr));
});
cmd.on('close', function(code){
if (!!code) that.emit('error', new gutil.PluginError(PLUGIN, buffer.toString()));
if (!!code) fail(that, 'docgen', buffer);
else {
that.push(new gutil.File({
path: '.',
Expand All @@ -148,6 +148,11 @@ function docgen(opts) {
});
}

function fail(plugin, tool, buffer) {
var msg = buffer.toString();
plugin.emit('error', new gutil.PluginError(PLUGIN, tool + ' has failed' + (msg ? ': ' + msg : '')));
}

module.exports = {
docgen: docgen,
psc: psc,
Expand Down