r2015 + output more user-friendly error messages on LiveVLANs tab
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 30 Jun 2008 23:44:04 +0000 (23:44 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 30 Jun 2008 23:44:04 +0000 (23:44 +0000)
gateways/switchvlans/main
inc/gateways.php

index 565b3b2267a56247906cf5e61da7e68702f03d32..25f22f851fa9ebdbff5dc9362fd53061f9d83a65 100755 (executable)
@@ -28,6 +28,39 @@ handler=
 CONNECTED=0
 MYDIR=`dirname $0`
 
+decode_error()
+{
+       case "$1" in
+               0)
+                       echo -n 'success'
+               ;;
+               1)
+                       echo -n 'internal error 1'
+               ;;
+               2)
+                       echo -n 'internal error 2'
+               ;;
+               3)
+                       echo -n 'password not found'
+               ;;
+               4)
+                       echo -n 'invalid password'
+               ;;
+               5)
+                       echo -n 'cannot create temporary files'
+               ;;
+               6)
+                       echo -n 'invalid command'
+               ;;
+               7)
+                       echo -n 'unknown host OS'
+               ;;
+               *)
+                       echo -n 'unknown error'
+               ;;
+       esac
+}
+
 # Not only connect, but gather all the data at once and remember the context.
 do_connect()
 {
@@ -76,7 +109,9 @@ do_connect()
                CONNECTED=1
                echo "OK!connected to $endpoint";
        else
-               echo "ERR!Cannot connect to $endpoint, connector returned code $ret"
+               echo -n "ERR!Cannot connect to $endpoint ("
+               decode_error $ret
+               echo ')'
        fi
 }
 
index 49034245ac9d819d888558163937fb5de041cb23..d0df624b35c29f026b64d6af3a7cee4e71a72297 100644 (file)
@@ -109,7 +109,7 @@ function getSwitchVLANs ($object_id = 0)
        }
        if (strpos ($data[0], 'OK!') !== 0)
        {
-               showError ("Gateway failure: returned code ${data[0]}.", __FUNCTION__);
+               showError ("Gateway failure: ${data[0]}.", __FUNCTION__);
                return NULL;
        }
        if (count ($data) != count ($commands))