Skip to content

Commit

Permalink
display build errors on simulator. fixes #247
Browse files Browse the repository at this point in the history
  • Loading branch information
yofreke committed Nov 29, 2015
1 parent 224fafd commit b763610
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ exports.build = function (appPath, argv, cb) {
return logger.error('another build is already in progress');
}

logger.error(err);
logger.log('build failed');
logger.info('build failed');
logger.error('exception: ' + err.stack);
if (process.send) {
process.send({
err: err.stack
});
}
process.exit(1);
})
.success(function () {
Expand Down
6 changes: 6 additions & 0 deletions src/serve/appRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ exports.addToAPI = function (opts, api) {
);
});
}
})
.catch(function(e) {
logger.error('Error building app', e);
res.status(500).send({
message: e
});
});
})
.catch(function (e) {
Expand Down
6 changes: 4 additions & 2 deletions src/serve/buildQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var BuildItem = Class(function () {

logger.log('starting build', this.appPath, this.buildOpts.target);

this._build = childProcess.fork(buildFork, [(args)])
this._build = childProcess.fork(buildFork, [args])
.on('message', this._onFinish.bind(this))
.on('close', this._onClose.bind(this));
};
Expand Down Expand Up @@ -118,7 +118,9 @@ var BuildItem = Class(function () {
// if the fork terminated normally, done will be true here
if (this.done) { return; }

this._reject({message: 'build failed'});
this._reject({
message: 'build failed (closed before done)'
});
this.done = true;
if (this._onStop) {
this._onStop();
Expand Down
8 changes: 8 additions & 0 deletions src/web/Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ var Simulator = exports = Class(function () {
}, function (err) {
this.logger.error('Unable to simulate', this._app);
this.logger.error(err);

this._requiresHardRebuild = true;

if (err.response && err.response.message) {
this._ui.showBuildFailed(err.response.message);
} else {
this._ui.showBuildFailed('Unknown failure, please check devkit server logs.');
}
});
});

Expand Down
10 changes: 10 additions & 0 deletions src/web/stylesheets/simulator.styl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ else
width 100%
height 100%

#buildFailedContainer
position absolute
top 0px
left 0px
width 100%
height 100%
padding 20px
background rgba(40, 0, 0, 0.7)
word-wrap break-word

.spinnerContainer
position absolute
top 0px
Expand Down
16 changes: 15 additions & 1 deletion src/web/ui/Chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ exports = Class(CenterLayout, function (supr) {
{id: 'background', type: FrameBackground},
{id: 'splashImage'},
{id: 'resizeHandle'},
{id: 'buildFailedContainer', children: [
{tag: 'h3', text: 'Build failed'},
{id: 'buildFailedMessage', tag: 'p', text: '<message>'}
]},
{id: 'build-spinner', class: 'spinnerContainer', children: [
{class: 'spinner'},
{tag: 'p', text: 'Building app'}
Expand Down Expand Up @@ -90,6 +94,8 @@ exports = Class(CenterLayout, function (supr) {
this.buildWidget = function () {
supr(this, 'buildWidget', arguments);

$.style(this['buildFailedContainer'], {display: 'none'});

var opts = this._opts;

this._validOrientations = {};
Expand Down Expand Up @@ -223,10 +229,11 @@ exports = Class(CenterLayout, function (supr) {
};

this.setBuilding = function (isBuilding) {

// Make sure we remove game simulation overhead when building
this.setPaused(isBuilding);

$.style(this['buildFailedContainer'], {display: 'none'});

var spinner = this['build-spinner'];

if (!isBuilding) {
Expand All @@ -245,6 +252,13 @@ exports = Class(CenterLayout, function (supr) {
}
};

this.showBuildFailed = function(msg) {
$.style(this['buildFailedContainer'], {display: 'block'});
$.removeClass(this['build-spinner'], 'visible');

$.setText(this.buildFailedMessage, msg);
};

this._onMenuOpen = function (menu) {
$.addClass(this.toolbar, 'menu-open');
if (menu == this.overflowMenu) {
Expand Down

0 comments on commit b763610

Please sign in to comment.