pvomacka's pull request #72: "WebUI: Add handling for HTTP error 404" was opened

PR body:
"""
In case that API is not accessible the 404 error is thrown. There was error 
dialog
with almost no information. The new dialog says what error is there and what 
can be
the main cause of the error.

https://fedorahosted.org/freeipa/ticket/4821
"""

See the full pull-request at https://github.com/freeipa/freeipa/pull/72
... or pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/72/head:pr72
git checkout pr72
From 90315fd79744ba7c5d3f4ab154e07e5ccb7fe813 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 24 Aug 2016 18:55:18 +0200
Subject: [PATCH] WebUI: Add handling for HTTP error 404

In case that API is not accessible the 404 error is thrown. There was error dialog
with almost no information. The new dialog says what error is there and what can be
the main cause of the error.

https://fedorahosted.org/freeipa/ticket/4821
---
 install/ui/src/freeipa/rpc.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js
index e2257a9..65bed77 100644
--- a/install/ui/src/freeipa/rpc.js
+++ b/install/ui/src/freeipa/rpc.js
@@ -124,7 +124,8 @@ rpc.command = function(spec) {
 
     /** @property {ordered_map.<number,string>} error_messages Error messages map */
     that.error_messages = $.ordered_map({
-        911: 'Missing HTTP referer. You have to configure your browser to send HTTP referer header.'
+        911: 'Missing HTTP referer. You have to configure your browser to send HTTP referer header.',
+        404: 'Cannot connect to the server, please check API accesibility (certificate, API, proxy, etc.)'
     });
 
     /**
@@ -317,6 +318,12 @@ rpc.command = function(spec) {
             if (xhr.status === 401) {
                 error_handler_auth(xhr, text_status, error_thrown);
                 return;
+            } else if (xhr.status === 404) {
+                error_thrown = {
+                    code: xhr.status,
+                    name: xhr.responseText || text.get('@i18n:errors.http_error',
+                                                    'HTTP Error')+' '+xhr.status
+                };
             } else if (!error_thrown) {
                 error_thrown = {
                     name: xhr.responseText || text.get('@i18n:errors.unknown_error', 'Unknown Error'),
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to