On 06/15/2011 09:23 PM, Endi Sukma Dewata wrote:
On 6/15/2011 6:44 PM, Adam Young wrote:
On 06/15/2011 02:37 PM, Adam Young wrote:
Part 2

https://fedorahosted.org/freeipa/ticket/1281

Now iterates through a list of known error types.

If the server is down (service ipa stop) it throws an error with name 'NS_ERROR_NOT_AVAILABLE' which is not in the list, so it still does a redirection.

There is another problem too, if the error name matches the list it doesn't call report_error().

Maybe this should be done the other way around. Instead of listing the errors not to redirect, we should list the errors which require redirection, i.e. IPA Error 4001 (entry not found).

This is optional, in ipa.js:337 we could add the IPA error code into the error_thrown object. This way the error can be checked more reliably using error code rather than error name.

This version does the whitelist approach
From b07476f92e2ad6f1f3844348127967166bb51d02 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Wed, 15 Jun 2011 14:34:54 -0400
Subject: [PATCH] no redirect on unknown error If the error name is indicates
 a server wide error, do not attempt to redirect.

this variation has a whitelist of errors on which to redirect.

https://fedorahosted.org/freeipa/ticket/1281
---
 install/ui/entity.js |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/install/ui/entity.js b/install/ui/entity.js
index 8ccdb8ea26820f3ec48ab73c5c5b3fb202ba157d..afe1e24b2c0f775a0bc3d17104a09d26d943b00b 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -136,20 +136,33 @@ IPA.facet = function (spec) {
         details.append('<p>'+error_thrown.message+'</p>');
     };
 
+    that.redirect_on_error = function(){
+        var current_entity = that.entity;
+        while (current_entity.containing_entity){
+            current_entity = current_entity.containing_entity;
+        }
+        IPA.nav.show_page(
+            current_entity.name,
+            that.entity.redirect_facet);
+    };
+
+    var redirect_errors =
+        ["IPA Error 4001"];
+
     that.on_error = function(xhr, text_status, error_thrown) {
+
+        /*If the error is in talking to the server, don't attempt to redirect,
+          as there is nothing any other facet can do either. */
         if (that.entity.redirect_facet )
         {
-            var current_entity = that.entity;
-            while (current_entity.containing_entity){
-                current_entity = current_entity.containing_entity;
+            for (var i =0; i <  redirect_errors.length; i += 1){
+                if (error_thrown.name ===  redirect_errors[i]){
+                    that.redirect_on_error();
+                    return;
+                }
             }
-            IPA.nav.show_page(
-                current_entity.name,
-                that.entity.redirect_facet);
-            return;
-        }else{
-            that.report_error(error_thrown);
         }
+        that.report_error(error_thrown);
     };
 
 
-- 
1.7.5.2

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to