Skip to content
This repository

[fix] Change callback order in error handling #420

Merged
merged 1 commit into from over 1 year ago

2 participants

Julian Duque Maciej Małecki
Julian Duque
Collaborator

The callback was being called before the message was shown to the user.

Maciej Małecki mmalecki merged commit 17d64d1 into from
Maciej Małecki mmalecki closed this
Maciej Małecki mmalecki deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 20, 2013
Julian Duque julianduque [fix] Change callback order in error handling b6d7d41
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 16 additions and 16 deletions. Show diff stats Hide diff stats

  1. +16 16 lib/jitsu.js
32 lib/jitsu.js
@@ -35,7 +35,7 @@ jitsu.use(flatiron.plugins.cli, {
35 35 string: true
36 36 },
37 37 jitsuconf: {
38   - alias: 'j',
  38 + alias: 'j',
39 39 description: 'specify file to load configuration from',
40 40 string: true
41 41 },
@@ -76,7 +76,7 @@ jitsu.options.log = {
76 76 // Setup config, users, command aliases and prompt settings
77 77 //
78 78 jitsu.prompt.properties = flatiron.common.mixin(
79   - jitsu.prompt.properties,
  79 + jitsu.prompt.properties,
80 80 require('./jitsu/properties')
81 81 );
82 82 jitsu.prompt.override = jitsu.argv;
@@ -124,7 +124,7 @@ jitsu.welcome = function () {
124 124 // #### @callback {function} Continuation to pass control to when complete.
125 125 // Starts the jitsu CLI and runs the specified command.
126 126 //
127   -jitsu.start = function (callback) {
  127 +jitsu.start = function (callback) {
128 128 //
129 129 // Check for --no-colors/--colors option, without hitting the config file
130 130 // yet
@@ -144,8 +144,8 @@ jitsu.start = function (callback) {
144 144 jitsu.init(function (err) {
145 145 if (err) {
146 146 jitsu.welcome();
147   - callback(err);
148   - return jitsu.showError(jitsu.argv._.join(' '), err);
  147 + jitsu.showError(jitsu.argv._.join(' '), err);
  148 + return callback(err);
149 149 }
150 150
151 151 jitsu.common.checkVersion(function (err) {
@@ -178,8 +178,8 @@ jitsu.start = function (callback) {
178 178 if (!username && jitsu.config.get('requiresAuth').indexOf(jitsu.argv._[0]) !== -1) {
179 179 return jitsu.commands.users.login(function (err) {
180 180 if (err) {
181   - callback(err);
182   - return jitsu.showError(jitsu.argv._.join(' '), err);
  181 + jitsu.showError(jitsu.argv._.join(' '), err);
  182 + return callback(err);
183 183 }
184 184
185 185 var username = jitsu.config.get('username');
@@ -233,8 +233,8 @@ jitsu.exec = function (command, callback) {
233 233 jitsu.log.info('Executing command ' + command.join(' ').magenta);
234 234 jitsu.router.dispatch('on', command.join(' '), jitsu.log, function (err, shallow) {
235 235 if (err) {
236   - callback(err);
237   - return jitsu.showError(command.join(' '), err, shallow);
  236 + jitsu.showError(command.join(' '), err, shallow);
  237 + return callback(err);
238 238 }
239 239
240 240 //
@@ -253,7 +253,7 @@ jitsu.exec = function (command, callback) {
253 253 // Sets up the instances of the Resource clients for jitsu.
254 254 // there is no io here, yet this function is ASYNC.
255 255 //
256   -jitsu.setup = function (callback) {
  256 +jitsu.setup = function (callback) {
257 257 if (jitsu.started === true) {
258 258 return callback();
259 259 }
@@ -304,7 +304,7 @@ jitsu.showError = function (command, err, shallow, skip) {
304 304 }
305 305 else if (!skip) {
306 306 jitsu.log.error('Error running command ' + command.magenta);
307   -
  307 +
308 308 if (!jitsu.config.get('nolog')) {
309 309 jitsu.logFile.log(err);
310 310 }
@@ -328,7 +328,7 @@ jitsu.showError = function (command, err, shallow, skip) {
328 328 jitsu.log.error('');
329 329 jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
330 330 }
331   -
  331 +
332 332 jitsu.log.error('Error output from app:');
333 333 jitsu.log.error('');
334 334 if (err.result.result.error.stdout) {
@@ -336,7 +336,7 @@ jitsu.showError = function (command, err, shallow, skip) {
336 336 jitsu.log.error(line);
337 337 });
338 338 }
339   -
  339 +
340 340 if (err.result.result.error.stderr) {
341 341 err.result.result.error.stderr.split('\n').forEach(function (line) {
342 342 jitsu.log.error(line);
@@ -347,13 +347,13 @@ jitsu.showError = function (command, err, shallow, skip) {
347 347 jitsu.log.error('There was an error while attempting to deploy the app');
348 348 jitsu.log.error('');
349 349 jitsu.log.error(err.result.result.error.message);
350   -
  350 +
351 351 if (err.result.result.error.blame) {
352 352 jitsu.log.error(err.result.result.error.blame.message);
353 353 jitsu.log.error('');
354 354 jitsu.log.error('This type of error is usually a ' + err.result.result.error.blame.type + ' error.');
355   - }
356   -
  355 + }
  356 +
357 357 jitsu.log.error('Error output from Haibu:');
358 358 jitsu.log.error('');
359 359 stack = err.result.result.error.result || err.result.result.error.stack;

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.