From 584c7955125c408333caf4033770604ddf38d57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Fri, 3 Apr 2015 20:07:11 +0000 Subject: [PATCH] Replace hard-coded error message with props. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that errors that happen when pulling image layers bubble up to the UI. We do this by catching errors coming from the docker client, calling the callback with that error and setting the global variable `_error` as the error we just caught. This is to make sure that when the stream ends we call the callback with the error as well as to not to over-ride it. Finally we remove the hard-coded message in the UI and display the error that gets passed in to it through the props attribute. This is the only part I'm not super sure on if we really want since it must have been set there for a reason. If I can get a re-producible test case I can make sure that it's still passing with this patch. Fixes #355. Signed-off-by: Kristján Oddsson --- src/ContainerHome.react.js | 4 +++- src/ContainerStore.js | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ContainerHome.react.js b/src/ContainerHome.react.js index bb3c4655f1..de13f769c0 100644 --- a/src/ContainerHome.react.js +++ b/src/ContainerHome.react.js @@ -74,7 +74,9 @@ var ContainerHome = React.createClass({ if (this.props.error) { body = (
-

There was a problem connecting to the Docker Engine in the VirtualBox VM.
This could be caused because this Mac is currently connected to a VPN, blocking access to the VM. If the issue persists, please file a ticket on our GitHub repo.

+

An error occurred:

+

{this.props.error}

+

If you feel that this error is invalid, please file a ticket on our GitHub repo.

); diff --git a/src/ContainerStore.js b/src/ContainerStore.js index b0cc3940df..109a022d19 100644 --- a/src/ContainerStore.js +++ b/src/ContainerStore.js @@ -56,6 +56,12 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), { var data = JSON.parse(str); console.log(data); + if (data.error) { + _error = data.error; + callback(data.error); + return; + } + if (data.status && (data.status === 'Pulling dependent layers' || data.status.indexOf('already being pulled by another client') !== -1)) { blockedCallback(); return; @@ -82,7 +88,8 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), { progressCallback(totalProgress); }); stream.on('end', function () { - callback(); + callback(_error); + _error = null; }); }); });