Skip to content

Commit

Permalink
[fix] Change callback order in error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
julianduque committed Mar 20, 2013
1 parent 478e96d commit b6d7d41
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/jitsu.js
Expand Up @@ -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
},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}

//
Expand All @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit b6d7d41

Please sign in to comment.