Skip to content
Permalink
Browse files

Merge pull request #420 from nodejitsu/correct-cb-order

[fix] Change callback order in error handling
  • Loading branch information...
mmalecki committed Mar 20, 2013
2 parents 478e96d + b6d7d41 commit 17d64d1f24df04f1ca900a4a35368544019034c5
Showing with 16 additions and 16 deletions.
  1. +16 −16 lib/jitsu.js
@@ -35,7 +35,7 @@ jitsu.use(flatiron.plugins.cli, {
string: true
},
jitsuconf: {
alias: 'j',
alias: 'j',
description: 'specify file to load configuration from',
string: true
},
@@ -76,7 +76,7 @@ jitsu.options.log = {
// Setup config, users, command aliases and prompt settings
//
jitsu.prompt.properties = flatiron.common.mixin(
jitsu.prompt.properties,
jitsu.prompt.properties,
require('./jitsu/properties')
);
jitsu.prompt.override = jitsu.argv;
@@ -124,7 +124,7 @@ jitsu.welcome = function () {
// #### @callback {function} Continuation to pass control to when complete.
// Starts the jitsu CLI and runs the specified command.
//
jitsu.start = function (callback) {
jitsu.start = function (callback) {
//
// Check for --no-colors/--colors option, without hitting the config file
// yet
@@ -144,8 +144,8 @@ jitsu.start = function (callback) {
jitsu.init(function (err) {
if (err) {
jitsu.welcome();
callback(err);
return jitsu.showError(jitsu.argv._.join(' '), err);
jitsu.showError(jitsu.argv._.join(' '), err);
return callback(err);
}

jitsu.common.checkVersion(function (err) {
@@ -178,8 +178,8 @@ jitsu.start = function (callback) {
if (!username && jitsu.config.get('requiresAuth').indexOf(jitsu.argv._[0]) !== -1) {
return jitsu.commands.users.login(function (err) {
if (err) {
callback(err);
return jitsu.showError(jitsu.argv._.join(' '), err);
jitsu.showError(jitsu.argv._.join(' '), err);
return callback(err);
}

var username = jitsu.config.get('username');
@@ -233,8 +233,8 @@ jitsu.exec = function (command, callback) {
jitsu.log.info('Executing command ' + command.join(' ').magenta);
jitsu.router.dispatch('on', command.join(' '), jitsu.log, function (err, shallow) {
if (err) {
callback(err);
return jitsu.showError(command.join(' '), err, shallow);
jitsu.showError(command.join(' '), err, shallow);
return callback(err);
}

//
@@ -253,7 +253,7 @@ jitsu.exec = function (command, callback) {
// Sets up the instances of the Resource clients for jitsu.
// there is no io here, yet this function is ASYNC.
//
jitsu.setup = function (callback) {
jitsu.setup = function (callback) {
if (jitsu.started === true) {
return callback();
}
@@ -304,7 +304,7 @@ jitsu.showError = function (command, err, shallow, skip) {
}
else if (!skip) {
jitsu.log.error('Error running command ' + command.magenta);

if (!jitsu.config.get('nolog')) {
jitsu.logFile.log(err);
}
@@ -328,15 +328,15 @@ jitsu.showError = function (command, err, shallow, skip) {
jitsu.log.error('');
jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
}

jitsu.log.error('Error output from app:');
jitsu.log.error('');
if (err.result.result.error.stdout) {
err.result.result.error.stdout.split('\n').forEach(function (line) {
jitsu.log.error(line);
});
}

if (err.result.result.error.stderr) {
err.result.result.error.stderr.split('\n').forEach(function (line) {
jitsu.log.error(line);
@@ -347,13 +347,13 @@ jitsu.showError = function (command, err, shallow, skip) {
jitsu.log.error('There was an error while attempting to deploy the app');
jitsu.log.error('');
jitsu.log.error(err.result.result.error.message);

if (err.result.result.error.blame) {
jitsu.log.error(err.result.result.error.blame.message);
jitsu.log.error('');
jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
}
}

jitsu.log.error('Error output from Haibu:');
jitsu.log.error('');
stack = err.result.result.error.result || err.result.result.error.stack;

0 comments on commit 17d64d1

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.