[Tkabber-dev] [tclxmpp] r128 committed - * xmpp/auth.tcl, xmpp/component.tcl, xmpp/compress.tcl, xmpp/iq.tcl, ...

tclxmpp at googlecode.com tclxmpp at googlecode.com
Tue Dec 29 16:01:16 MSK 2009


Revision: 128
Author: sgolovan
Date: Tue Dec 29 05:00:26 2009
Log: 	* xmpp/auth.tcl, xmpp/component.tcl, xmpp/compress.tcl, xmpp/iq.tcl,
	  xmpp/pconnect.tcl, xmpp/sasl.tcl, xmpp/starttls.tcl, xmpp/tcp.tcl,
	  xmpp/tls.tcl, xmpp/transport.tcl, xmpp/xml.tcl, xmpp/xmpp.tcl,
	  xmpp/zlib.tcl: Removed incorrect -errorinfo options from return
	  calls, and a bit improved error reporting in some catch calls.

http://code.google.com/p/tclxmpp/source/detail?r=128

Modified:
  /trunk/ChangeLog
  /trunk/xmpp/auth.tcl
  /trunk/xmpp/component.tcl
  /trunk/xmpp/compress.tcl
  /trunk/xmpp/iq.tcl
  /trunk/xmpp/pconnect.tcl
  /trunk/xmpp/sasl.tcl
  /trunk/xmpp/starttls.tcl
  /trunk/xmpp/tcp.tcl
  /trunk/xmpp/tls.tcl
  /trunk/xmpp/transport.tcl
  /trunk/xmpp/xml.tcl
  /trunk/xmpp/xmpp.tcl
  /trunk/xmpp/zlib.tcl

=======================================
--- /trunk/ChangeLog	Tue Oct 27 11:59:26 2009
+++ /trunk/ChangeLog	Tue Dec 29 05:00:26 2009
@@ -1,3 +1,11 @@
+2009-12-29  Sergei Golovan  <sgolovan at nes.ru>
+
+	* xmpp/auth.tcl, xmpp/component.tcl, xmpp/compress.tcl, xmpp/iq.tcl,
+	  xmpp/pconnect.tcl, xmpp/sasl.tcl, xmpp/starttls.tcl, xmpp/tcp.tcl,
+	  xmpp/tls.tcl, xmpp/transport.tcl, xmpp/xml.tcl, xmpp/xmpp.tcl,
+	  xmpp/zlib.tcl: Removed incorrect -errorinfo options from return
+	  calls, and a bit improved error reporting in some catch calls.
+
  2009-10-27  Sergei Golovan  <sgolovan at nes.ru>

  	* xmpp/poll.tcl, xmpp/xml.tcl: Removed trailing whitespaces.
=======================================
--- /trunk/xmpp/auth.tcl	Mon Aug 17 06:10:10 2009
+++ /trunk/xmpp/auth.tcl	Tue Dec 29 05:00:26 2009
@@ -101,15 +101,13 @@
                  } else {
                      unset state
                      return -code error \
-                           -errorinfo [::msgcat::mc \
-                                           "Illegal value \"%s\" for\
-                                            option \"%s\"" $val $key]
+                           [::msgcat::mc "Illegal value \"%s\" for\
+                                          option \"%s\"" $val $key]
                  }
              }
              default {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -120,8 +118,7 @@
                   -resource} {
          if {![info exists state($key)]} {
              unset state
-            return -code error \
-                   -errorinfo [::msgcat::mc "Missing option \"%s\"" $key]
+            return -code error [::msgcat::mc "Missing option \"%s\"" $key]
          }
      }

=======================================
--- /trunk/xmpp/component.tcl	Mon Aug 17 06:10:10 2009
+++ /trunk/xmpp/component.tcl	Tue Dec 29 05:00:26 2009
@@ -81,8 +81,7 @@
              }
              default {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -91,8 +90,7 @@
                   -secret} {
          if {![info exists state($key)]} {
              unset state
-            return -code error \
-                   -errorinfo [::msgcat::mc "Missing option \"%s\"" $key]
+            return -code error [::msgcat::mc "Missing option \"%s\"" $key]
          }
      }

=======================================
--- /trunk/xmpp/compress.tcl	Mon Aug 17 06:10:10 2009
+++ /trunk/xmpp/compress.tcl	Tue Dec 29 05:00:26 2009
@@ -89,8 +89,7 @@
                  set timeout $val
              }
              default {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
=======================================
--- /trunk/xmpp/iq.tcl	Thu Mar  5 10:39:21 2009
+++ /trunk/xmpp/iq.tcl	Tue Dec 29 05:00:26 2009
@@ -116,8 +116,7 @@
          get -
          set {}
          default {
-            return -code error \
-                   -errorinfo [::msgcat::mc "Illegal IQ type \"%s\"" $type]
+            return -code error [::msgcat::mc "Illegal IQ type \"%s\""  
$type]
          }
      }

=======================================
--- /trunk/xmpp/pconnect.tcl	Sun Mar 29 09:12:27 2009
+++ /trunk/xmpp/pconnect.tcl	Tue Dec 29 05:00:26 2009
@@ -214,8 +214,7 @@
      upvar 0 $token state

      if {![info exists $token]} {
-        return -code error \
-               -errorinfo "Connection either established or failed already"
+        return -code error "Connection either established or failed  
already"
      }

      set proxy $state(-proxy)
=======================================
--- /trunk/xmpp/sasl.tcl	Mon Aug 17 06:10:10 2009
+++ /trunk/xmpp/sasl.tcl	Tue Dec 29 05:00:26 2009
@@ -35,7 +35,7 @@
              set encodeToUTF8 1
          }
      } else {
-        return -code error -errorinfo [::msgcat::mc "No SASL package  
found"]
+        return -code error [::msgcat::mc "No SASL package found"]
      }

      switch -- $saslpack {
@@ -113,15 +113,13 @@
                  } else {
                      unset state
                      return -code error \
-                           -errorinfo [::msgcat::mc \
-                                           "Illegal value \"%s\" for\
-                                            option \"%s\"" $val $key]
+                           [::msgcat::mc "Illegal value \"%s\" for\
+                                          option \"%s\"" $val $key]
                  }
              }
              default {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -134,9 +132,8 @@
      }
      if {$count >= 2} {
          unset state
-        return -code error \
-               -errorinfo [::msgcat::mc "Only one option \"-username\"\
-                                         or \"-domain\" is allowed"]
+        return -code error [::msgcat::mc "Only one option \"-username\"\
+                                          or \"-domain\" is allowed"]
      }

      if {[info exists state(-username)]} {
@@ -144,23 +141,20 @@
                       -password} {
              if {![info exists state($key)]} {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Missing option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Missing option \"%s\""  
$key]
              }
          }
      } elseif {[info exists state(-domain)]} {
          foreach key {-secret} {
              if {![info exists state($key)]} {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Missing option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Missing option \"%s\""  
$key]
              }
          }
      } else {
          unset state
-        return -code error \
-               -errorinfo [::msgcat::mc "Missing option \"-username\"\
-                                         or \"-domain\""]
+        return -code error [::msgcat::mc "Missing option \"-username\"\
+                                          or \"-domain\""]
      }

      ::xmpp::RegisterElement $xlib * urn:ietf:params:xml:ns:xmpp-sasl \
@@ -193,9 +187,8 @@
                  set flags {}
              } else {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Cannot forbid digest\
-                                                 mechanisms"]
+                return -code error [::msgcat::mc "Cannot forbid digest\
+                                                  mechanisms"]
              }

              $state(token) -operation setprop \
=======================================
--- /trunk/xmpp/starttls.tcl	Mon Aug 17 06:10:10 2009
+++ /trunk/xmpp/starttls.tcl	Tue Dec 29 05:00:26 2009
@@ -108,8 +108,7 @@
              }
              default {
                  unset state
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
=======================================
--- /trunk/xmpp/tcp.tcl	Mon Feb 23 06:48:06 2009
+++ /trunk/xmpp/tcp.tcl	Tue Dec 29 05:00:26 2009
@@ -372,10 +372,8 @@
      variable $token
      upvar 0 $token state

-    catch {
-        fileevent $state(sock) readable {}
-        ::close $state(sock)
-    }
+    catch {fileevent $state(sock) readable {}}
+    catch {::close $state(sock)}

      if {[info exists state(parser)]} {
          ::xmpp::xml::free $state(parser)
=======================================
--- /trunk/xmpp/tls.tcl	Mon Feb 23 06:48:06 2009
+++ /trunk/xmpp/tls.tcl	Tue Dec 29 05:00:26 2009
@@ -292,8 +292,7 @@
      if {[catch {::tls::handshake $state(sock)} result]} {
          catch {::close $state(sock)}
          # TODO: Cleanup.
-        return -code error \
-               -errorinfo [::msgcat::mc "TLS handshake failed: %s" $result]
+        return -code error [::msgcat::mc "TLS handshake failed: %s"  
$result]
      }

      fconfigure $state(sock) -blocking    false \
@@ -495,10 +494,8 @@
      variable $token
      upvar 0 $token state

-    catch {
-        fileevent $state(sock) readable {}
-        ::close $state(sock)
-    }
+    catch {fileevent $state(sock) readable {}}
+    catch {::close $state(sock)}

      if {[info exists state(parser)]} {
          ::xmpp::xml::free $state(parser)
=======================================
--- /trunk/xmpp/transport.tcl	Mon Feb 23 06:48:06 2009
+++ /trunk/xmpp/transport.tcl	Tue Dec 29 05:00:26 2009
@@ -78,9 +78,8 @@
      variable Transports

      if {[lsearch -exact $TransportsList $transport] >= 0} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Transport \"%s\" already\
-                                         registered" $transport]
+        return -code error [::msgcat::mc "Transport \"%s\" already\
+                                          registered" $transport]
      }

      foreach {key val} $args {
@@ -99,8 +98,7 @@
                  set attrs($key) $val
              }
              default {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -118,8 +116,7 @@
                   -closestreamcommand} {
          if {![info exists attrs($key)]} {
              unset Transports($transport)
-            return -code error \
-                   -errorinfo [::msgcat::mc "Missing option \"%s\"" $key]
+            return -code error [::msgcat::mc "Missing option \"%s\"" $key]
          } else {
              lappend Transports($transport) $key $attrs($key)
          }
@@ -154,8 +151,7 @@
      variable Transports

      if {[set idx [lsearch -exact $TransportsList $transport]] < 0} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Unknown transport \"%s\""  
$transport]
+        return -code error [::msgcat::mc "Unknown transport \"%s\""  
$transport]
      } else {
          set TransportsList [lreplace $TransportsList $idx $idx]
          unset $Transports($transport)
@@ -169,8 +165,7 @@
      variable Transports

      if {[lsearch -exact $TransportsList $transport] < 0} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Unknown transport \"%s\""  
$transport]
+        return -code error [::msgcat::mc "Unknown transport \"%s\""  
$transport]
      }

      array set attrs $Transports($transport)
@@ -205,8 +200,7 @@
      set transport $state(transport)

      if {[lsearch -exact $TransportsList $transport] < 0} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Unknown transport \"%s\""  
$transport]
+        return -code error [::msgcat::mc "Unknown transport \"%s\""  
$transport]
      }

      ::switch -- $command {
@@ -220,8 +214,7 @@
          openStream  {set key -openstreamcommand}
          closeStream {set key -closestreamcommand}
          default {
-            return -code error \
-                   -errorinfo [::msgcat::mc "Illegal command \"%s\""  
$command]
+            return -code error [::msgcat::mc "Illegal command \"%s\""  
$command]
          }
      }

@@ -251,8 +244,7 @@
      variable Transports

      if {[lsearch -exact $TransportsList $transport] < 0} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Unknown transport \"%s\""  
$transport]
+        return -code error [::msgcat::mc "Unknown transport \"%s\""  
$transport]
      }

      array set attrs $Transports($transport)
@@ -262,8 +254,8 @@
          } token2]} {

          return -code error \
-               -errorinfo [::msgcat::mc "Can't switch transport to  
\"%s\": %s" \
-                                        $transport $token2]
+               [::msgcat::mc "Can't switch transport to \"%s\": %s" \
+                             $transport $token2]
      } else {
          return $token2
      }
=======================================
--- /trunk/xmpp/xml.tcl	Tue Oct 27 11:59:26 2009
+++ /trunk/xmpp/xml.tcl	Tue Dec 29 05:00:26 2009
@@ -94,8 +94,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      $state(parser) free
@@ -123,8 +122,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      # TODO: catch and process errors
@@ -149,8 +147,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      $state(parser) reset
@@ -362,10 +359,8 @@
                  foreach {attr value} $val {
                      if {[string equal $attr xmlns]} {
                          return -code error \
-                               -errorinfo \
-                                    [::msgcat::mc \
-                                            "Illegal attribute \"xmlns\".\
-                                             Use -xmlns option"]
+                               [::msgcat::mc "Illegal attribute \"xmlns\".\
+                                              Use -xmlns option"]
                      }
                      lappend attrs $attr $value
                  }
@@ -401,8 +396,7 @@
                  }
              }
              default {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Invalid option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Invalid option \"%s\""  
$key]
              }
          }
      }
@@ -605,15 +599,13 @@
      if {[isAttr $args -xmlns:stream]} {
          set xmlns_stream [getAttr $args -xmlns:stream]
      } else {
-        return -code error \
-               -errorinfo [::msgcat::mc "Missing option \"%s\""  
-xmlns:stream]
+        return -code error [::msgcat::mc "Missing option \"%s\""  
-xmlns:stream]
      }

      if {[isAttr $args -xmlns]} {
          set xmlns [getAttr $args -xmlns]
      } else {
-        return -code error \
-               -errorinfo [::msgcat::mc "Missing option \"%s\"" -xmlns]
+        return -code error [::msgcat::mc "Missing option \"%s\"" -xmlns]
      }

      set retext "<stream:stream xmlns:stream='[Escape $xmlns_stream]'\
@@ -630,8 +622,7 @@
              -xmlns:stream -
              -xmlns {}
              default {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Invalid option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Invalid option \"%s\""  
$key]
              }
          }
      }
@@ -841,8 +832,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      array set namespace [lindex $state(namespace) end]
@@ -924,8 +914,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      set state(namespace) [lreplace $state(namespace) end end]
@@ -969,8 +958,7 @@
      upvar 0 $token state

      if {![info exists state(parser)]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
+        return -code error [::msgcat::mc "Parser \"%s\" doesn't exist"  
$token]
      }

      set newEl [lindex $state(stack) 0]
=======================================
--- /trunk/xmpp/xmpp.tcl	Mon Feb 23 06:48:06 2009
+++ /trunk/xmpp/xmpp.tcl	Tue Dec 29 05:00:26 2009
@@ -70,9 +70,8 @@

          if {[info exists $xlib]} {
              return -code error \
-                   -errorinfo [::msgcat::mc "An existing variable \"%s\"\
-                                             cannot be used as an XMPP\
-                                             token" $xlib]
+                   [::msgcat::mc "An existing variable \"%s\" cannot be  
used\
+                                  as an XMPP token" $xlib]
          }
      } else {
          set xlib [namespace current]::[incr id]
@@ -97,8 +96,7 @@
                  set attrs($key) $val
              }
              default {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -158,8 +156,7 @@
      Debug $xlib 2 ""

      if {![status $xlib disconnected]} {
-        return -code error \
-               -errorinfo [::msgcat::mc "Free without disconnect"]
+        return -code error [::msgcat::mc "Free without disconnect"]
      }

      if {[info exists state(-messagecommand)]} {
@@ -437,9 +434,8 @@
              -xmlns:stream {
                  if {![string equal $val http://etherx.jabber.org/streams]}  
{
                      return -code error \
-                           -errorinfo [::msgcat::mc \
-                                           "Unsupported stream XMLNS  
\"%s\"" \
-                                           $val]
+                           [::msgcat::mc "Unsupported stream XMLNS \"%s\""  
\
+                                         $val]
                  }
              }
              -xmlns -
@@ -455,8 +451,7 @@
                  set state(openStreamCommand) $val
              }
              default  {
-                return -code error \
-                       -errorinfo [::msgcat::mc "Illegal option \"%s\""  
$key]
+                return -code error [::msgcat::mc "Illegal option \"%s\""  
$key]
              }
          }
      }
@@ -960,10 +955,10 @@
                  catch {unset state(abortCommand)}
              }

-            catch {
-                transport::use $state(transport) close
-                unset state(transport)
-            }
+            if {[catch {transport::use $state(transport) close} msg]} {
+                Debug $xlib 1 "Closing connection failed: $msg"
+            }
+            catch {unset state(transport)}

              CallBack $xlib disconnect

@@ -1006,11 +1001,13 @@
                  catch {unset state(abortCommand)}
              }

-            catch {
-                closeStream $xlib
-                transport::use $state(transport) close
-                unset state(transport)
-            }
+            if {[catch {closeStream $xlib} msg]} {
+                Debug $xlib 1 "Closing stream failed: $msg"
+            }
+            if {[catch {transport::use $state(transport) close} msg]} {
+                Debug $xlib 1 "Closing connection failed: $msg"
+            }
+            catch {unset state(transport)}

              ClearState $xlib
          }
@@ -1661,9 +1658,8 @@
                  # Option -command makes sense for get or set IQs only
                  if {!$getset} {
                      return -code error \
-                           -errorinfo [::msgcat::mc "Option \"-command\"  
is\
-                                                     illegal for IQ type\
-                                                     \"%s\"" $attrs(type)]
+                           [::msgcat::mc "Option \"-command\" is illegal  
for\
+                                          IQ type \"%s\"" $attrs(type)]
                  }

                  # Only the last -command takes effect
=======================================
--- /trunk/xmpp/zlib.tcl	Fri Mar 27 12:10:38 2009
+++ /trunk/xmpp/zlib.tcl	Tue Dec 29 05:00:26 2009
@@ -437,10 +437,8 @@
      variable $token
      upvar 0 $token state

-    catch {
-        fileevent $state(sock) readable {}
-        ::close $state(sock)
-    }
+    catch {fileevent $state(sock) readable {}}
+    catch {::close $state(sock)}

      if {[info exists state(parser)]} {
          ::xmpp::xml::free $state(parser)


More information about the Tkabber-dev mailing list