Improved errors and native logic

Signed-off-by: French Ben <me+git@frenchben.com>
This commit is contained in:
French Ben 2016-04-12 17:41:05 -07:00
parent b8495ee800
commit 1a03a83d00
4 changed files with 19 additions and 8 deletions

View File

@ -51,10 +51,20 @@ var ContainerHome = React.createClass({
let body;
if (this.props.container.Error) {
let error = this.props.container.Error.message;
console.log('Err: %o - %o', typeof error, error);
if (error.indexOf('ETIMEDOUT') !== -1) {
error = 'Timeout error - Try and restart your VM by running: \n"docker-machine restart default" in a terminal';
}
if (error.indexOf('ECONNREFUSED') !== -1) {
error = 'Is your VM up and running? Check that "docker ps" works in a terminal.';
}
body = (
<div className="details-progress error">
<h2>We&#39;re sorry. There seems to be an error:</h2>
<p className="error-message">{this.props.container.Error}</p>
{error.split('\n').map(i => {
return <p className="error-message">{i}</p>;
})}
<p>If this error is invalid, please file a ticket on our Github repo.</p>
<a className="btn btn-action" onClick={this.handleErrorClick}>File Ticket</a>
</div>

View File

@ -400,6 +400,7 @@ export default {
if (err) {
// socket hang up can be captured
console.error(err);
containerServerActions.error({name: this.activeContainerName, err});
return;
}

View File

@ -18,7 +18,6 @@ const precreateCheckExitCode = 3;
let _retryPromise = null;
let _timers = [];
let useNative = util.isNative() ? util.isNative() : true;
export default {
simulateProgress (estimateSeconds) {
@ -40,6 +39,7 @@ export default {
async useVbox () {
metrics.track('Retried Setup with VBox');
router.get().transitionTo('loading');
util.native = false;
setupServerActions.error({ error: { message: null }});
_retryPromise.resolve();
},

View File

@ -9,6 +9,7 @@ const dialog = remote.dialog;
const app = remote.app;
module.exports = {
native: null,
execFile: function (args, options) {
return new Promise((resolve, reject) => {
child_process.execFile(args[0], args.slice(1), options, (error, stdout) => {
@ -38,21 +39,20 @@ module.exports = {
return process.platform === 'linux';
},
isNative: function () {
let native = null;
if (native === null) {
if (this.native === null) {
try {
// Check if file exists
fs.statSync('/var/run/docker.sock');
native = true;
this.native = true;
} catch (e) {
if (this.isLinux()) {
native = true;
this.native = true;
} else {
native = false;
this.native = false;
}
}
}
return native;
return this.native;
},
binsPath: function () {
return this.isWindows() ? path.join(this.home(), 'Kitematic-bins') : path.join('/usr/local/bin');