From be2911707c2ac52b905eb16767734861144e3a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 29 Dec 2014 22:55:52 +0100 Subject: [PATCH] Displaying error message in queue if fails --- front/src/css/queue.css | 6 ++++- front/src/js/controllers/dashboardCtrl.js | 2 ++ front/src/less/queue.less | 7 +++++- front/src/views/queue.html | 27 ++++++++++++++------- lib/server/controllers/apiController.js | 5 ++-- lib/server/datastores/runsDatastore.js | 29 +++++++++++++++++++++-- 6 files changed, 61 insertions(+), 15 deletions(-) diff --git a/front/src/css/queue.css b/front/src/css/queue.css index 4a0e0e9..e847481 100644 --- a/front/src/css/queue.css +++ b/front/src/css/queue.css @@ -1,7 +1,11 @@ .status { - margin: 2em; + margin-top: 2em; font-size: 2.5em; } +.statusSubMessage { + font-size: 0.8em; + margin-bottom: 6em; +} .queueLink { color: #FFF; } diff --git a/front/src/js/controllers/dashboardCtrl.js b/front/src/js/controllers/dashboardCtrl.js index 2dac82b..64a76fd 100644 --- a/front/src/js/controllers/dashboardCtrl.js +++ b/front/src/js/controllers/dashboardCtrl.js @@ -12,6 +12,8 @@ dashboardCtrl.controller('DashboardCtrl', ['$scope', '$rootScope', '$routeParams $rootScope.loadedResult = result; $scope.result = result; init(); + }, function(err) { + alert('aie'); }); } else { $scope.result = $rootScope.loadedResult; diff --git a/front/src/less/queue.less b/front/src/less/queue.less index 39b0822..dc1181b 100644 --- a/front/src/less/queue.less +++ b/front/src/less/queue.less @@ -1,8 +1,13 @@ .status { - margin: 2em; + margin-top: 2em; font-size: 2.5em; } +.statusSubMessage { + font-size: 0.8em; + margin-bottom: 6em; +} + .queueLink { color: #FFF; } \ No newline at end of file diff --git a/front/src/views/queue.html b/front/src/views/queue.html index 93ecd1c..219d29f 100644 --- a/front/src/views/queue.html +++ b/front/src/views/queue.html @@ -1,14 +1,25 @@

Tested url:   {{url}}

-
Test failed :(
+
Test failed
+

{{status.error}}

Report a bug on GitHub

Back to index

-
- -
-
Test is running...
-
Test complete
\ No newline at end of file +
+
+ + +
+

(auto-refresh activated)

+
+
+
Test is running...
+

(auto-refresh activated)

+
+
+
Test complete
+

Opening results...

+
\ No newline at end of file diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index d76d458..6ff9345 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -75,10 +75,9 @@ var ApiController = function(app) { }).fail(function(err) { console.error('Test failed for %s', run.params.url); - console.error(err); - console.error(err.stack); + console.error(err.toString()); - runsDatastore.markAsFailed(run.runId); + runsDatastore.markAsFailed(run.runId, err.toString()); }).finally(function() { queue.remove(run.runId); diff --git a/lib/server/datastores/runsDatastore.js b/lib/server/datastores/runsDatastore.js index cf0af10..da9b5bb 100644 --- a/lib/server/datastores/runsDatastore.js +++ b/lib/server/datastores/runsDatastore.js @@ -53,11 +53,36 @@ function RunsDatastore() { }; - this.markAsFailed = function(runId) { + this.markAsFailed = function(runId, err) { var run = runs[runId]; + var errorMessage; + switch(err) { + case '252': + errorMessage = "Error 252: page timeout in Phantomas"; + break; + case '253': + errorMessage = "Error 253: Phantomas config error"; + break; + case '254': + errorMessage = "Error 254: page loading failed in Phantomas"; + break; + case '255': + errorMessage = "Error 255: Phantomas error"; + break; + case '1001': + errorMessage = "Error 1001: JavaScript profiling failed"; + break; + case '1002': + errorMessage = "Error 1002: missing Phantomas metrics"; + break; + default: + errorMessage = err; + } + run.status = { - statusCode: STATUS_FAILED + statusCode: STATUS_FAILED, + error: errorMessage }; runs[runId] = run;