No Warning



  • So my former roommate, recently featured on the front page of this site, sent me a message last night. I hadn't talked to him in at least a month and out of nowhere he sends me a chunk of "code" and asks me why it isn't working right. There was no warning, his first message was all code.

    I took a look at it, I screamed, and sent him a link to our former colleges library website, telling him to use the Safari Books subscription to learn something before bothering me again. Harsh yes, but given all my other attempts to help him. I've decided you can't help someone until they're willing to try to help themselves first.

     

    Count the WTFs:

    ------------------------- 

    Steve* says: 

    retry:
                Try

                    Client._Send("send something")

                Catch ex As Exception
                    Try
    'connection failed do to connection in progress
                        Thread.Sleep(20)

                        GoTo retry

                    Catch
                    End Try
                End Try


    if you could tell me why in a loop of 1000 messages, after about 100 sent the next one tells me the connection is in use, but the previous message has closed the client. an after a random number of retrys the message gets sent...

    ---------------


    At least you were warned. I wasn't.
     

    <hints id="hah_hints"></hints>


  • @AgentConundrum said:

    So my former roommate, recently featured on the front page of this site, sent me a message last night. I hadn't talked to him in at least a month and out of nowhere he sends me a chunk of "code" and asks me why it isn't working right. There was no warning, his first message was all code.

    I took a look at it, I screamed, and sent him a link to our former colleges library website, telling him to use the Safari Books subscription to learn something before bothering me again. Harsh yes, but given all my other attempts to help him. I've decided you can't help someone until they're willing to try to help themselves first.

     

    Count the WTFs:

    ------------------------- 

    Steve* says: 

    retry:
                Try

                    Client._Send("send something")

                Catch ex As Exception
                    Try
    'connection failed do to connection in progress
                        Thread.Sleep(20)

                        GoTo retry

                    Catch
                    End Try
                End Try


    if you could tell me why in a loop of 1000 messages, after about 100 sent the next one tells me the connection is in use, but the previous message has closed the client. an after a random number of retrys the message gets sent...

    ---------------


    At least you were warned. I wasn't.
     

    <hints id="hah_hints"></hints>

    interesting classname, empty catch block, it would be better used as a bunch of *if* statements

    short unsent

    Private class retry

        If (unsent==1) {

            set unsent to 0

           Client.Send ("SomethingOrOther")

            catch (e) {

                set unsent to 1 }

            goto retry}

         else { 

              Client.Send ("SomethingOrOther")

              catch (e)

                set unsent to 1}

              goto retry}



  • @Steeldragon said:

    @AgentConundrum said:

    So my former roommate, recently featured on the front page of this site, sent me a message last night. I hadn't talked to him in at least a month and out of nowhere he sends me a chunk of "code" and asks me why it isn't working right. There was no warning, his first message was all code.

    I took a look at it, I screamed, and sent him a link to our former colleges library website, telling him to use the Safari Books subscription to learn something before bothering me again. Harsh yes, but given all my other attempts to help him. I've decided you can't help someone until they're willing to try to help themselves first.

     

    Count the WTFs:

    ------------------------- 

    Steve* says: 

    retry:
                Try

                    Client._Send("send something")

                Catch ex As Exception
                    Try
    'connection failed do to connection in progress
                        Thread.Sleep(20)

                        GoTo retry

                    Catch
                    End Try
                End Try


    if you could tell me why in a loop of 1000 messages, after about 100 sent the next one tells me the connection is in use, but the previous message has closed the client. an after a random number of retrys the message gets sent...

    ---------------


    At least you were warned. I wasn't.
     

    <hints id="hah_hints"></hints>

    interesting classname, empty catch block, it would be better used as a bunch of *if* statements

    short unsent

    Private class retry

        If (unsent==1) {

            set unsent to 0

           Client.Send ("SomethingOrOther")

            catch (e) {

                set unsent to 1 }

            goto retry}

         else { 

              Client.Send ("SomethingOrOther")

              catch (e)

                set unsent to 1}

              goto retry}

     

    That's no class name.... 



  • That's interesting... I wonder what did he want to catch.

    Try
      Thread.Sleep(20)
      GoTo retry
    Catch ie As InsomniaException
    Catch lmvwge As LostMyWayWhileGotoingException
    Catch fnfe As FileNotFoundException ' Dunno, it always happens
    Catch e As Exception
      Throw e
    Catch
    Finally
    End Try



  • @AgentConundrum said:

     

    That's no class name.... 

    It's a SPACE STATION! 



  • I realized that after I said it. I watched all three star wars movies this past weekend. It must have slipped through.

     



  • @AgentConundrum said:

    So my former roommate, recently featured on the front page of this site, sent me a message last night. I hadn't talked to him in at least a month and out of nowhere he sends me a chunk of "code" and asks me why it isn't working right. There was no warning, his first message was all code.

    I took a look at it, I screamed, and sent him a link to our former colleges library website, telling him to use the Safari Books subscription to learn something before bothering me again. Harsh yes, but given all my other attempts to help him. I've decided you can't help someone until they're willing to try to help themselves first.

     

    Count the WTFs:

    ------------------------- 

    Steve* says: 

    retry:
                Try

                    Client._Send("send something")

                Catch ex As Exception
                    Try
    'connection failed do to connection in progress
                        Thread.Sleep(20)

                        GoTo retry

                    Catch
                    End Try
                End Try


    if you could tell me why in a loop of 1000 messages, after about 100 sent the next one tells me the connection is in use, but the previous message has closed the client. an after a random number of retrys the message gets sent...

    ---------------


    At least you were warned. I wasn't.
     

    <hints id="hah_hints"></hints>

    (psuedo-)WTF #1 - VB.NET (Had to say it before someone else does.)

    WTF #2 - Goto. This isn't hard to put in an unconditional Do/Loop block. Goto can be useful in some limited scenarios. This is not one of them.

    WTF #3 - Swallowing *all* exceptions - twice.

    WTF #4 - Blindly assuming a retry will fix. Like it'll fix a NullReferenceException, or an OutOfMemoryException, or something. Right...

    WTF #5 - Should only swallow InterruptedException (or whatever it's called in .net) around the sleep.

    WTF #6 - Calling a method (and/or having declared one) with leading _. Yes, this is legal for an identifier, but IIRC traditional VB convention was that leading _ was for "hidden" functions that generally weren't called directly. For example, Collections in VB6 frequently prefixed the enumerator function (where you could assign any name to that method (typically NewEnum for VB6-declared collections, or _NewEnum for ones pulled from COM libraries), you just assigned a specific method ID (that I no longer recall) in a method properties box I can no longer remember how to get to (other than through object browser), the whole COM thing gets involved here :P) with _ and marked it hidden, since these were meant to be automatically called when you used For Each. Other classes did similar things. Calling such a function directly required you to put square brackets ([]) around the method name. (As opposed to what you have to do to use Win32 functions with a leading _.)

    How I'd write it.

    Do
        Try
            Client._Send("send something")
        Catch ex As SendFailedException 'Exceptions indicating failures specific to this _Send function. Not generic stuff like TheFramewordBlewUpException or MicrosoftDoesntWorkException
            LogException(ex, "while trying to send something")
            Try
                Thread.Sleep(20)
            Catch ex2 As ThreadInterruptedException
                LogException(ex2, "while sleeping after exception while trying to sending something")
            End Try
            Continue Do 'for >=VB.NET 2005
        Catch ex As Exception
            LogException(ex, "while trying to send something")
            Throw
        End Try
        Exit Do
    Loop

    As for why he has problems, well... this, and probably I don't think his _Send() function is really any better.


Log in to reply