Click here to Skip to main content
15,886,026 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Exceptional coding Pin
Mycroft Holmes7-Jun-09 14:32
professionalMycroft Holmes7-Jun-09 14:32 
GeneralRe: Exceptional coding Pin
John R. Shaw19-Jun-09 20:05
John R. Shaw19-Jun-09 20:05 
GeneralRe: Exceptional coding Pin
Rick York6-Jun-09 8:38
mveRick York6-Jun-09 8:38 
GeneralRe: Exceptional coding Pin
Brady Kelly16-Jun-09 22:33
Brady Kelly16-Jun-09 22:33 
GeneralRe: Exceptional coding Pin
Judah Gabriel Himango17-Jun-09 5:15
sponsorJudah Gabriel Himango17-Jun-09 5:15 
GeneralRe: Exceptional coding Pin
Judah Gabriel Himango17-Jun-09 5:15
sponsorJudah Gabriel Himango17-Jun-09 5:15 
GeneralRe: Exceptional coding Pin
ssiegel22-Jun-09 14:42
ssiegel22-Jun-09 14:42 
GeneralMore an Implimentation Horror Pin
Nagy Vilmos2-Jun-09 11:04
professionalNagy Vilmos2-Jun-09 11:04 
0. This code is in the region of 10 years old and I only had VB (probably 5 at that point) to work with.
1. What the code does is, I think sound.

In each class these variables are defined:
Private mlErrNumber As Long         '** Standard Variable for Error Trapping **
Private msErrDescription As String  '** Standard Variable for Error Trapping **
Private msErrSource As String       '** Standard Variable for Error Trapping **


Then in any function or sub mlErrNumber = 0 clears the error state.
Not bad so far, slightly ott, but not bad.

So when an error occured, this was called to persist the error state to be used by any calling classes:
Private Sub SetError(ByVal alNumber As Long, _
                     ByVal asDescription As String, _
                     ByVal asSource As String, _
                     ByVal asLocation As String)
'================================================================================================
' Sub       : SetError
' Arguments : alNumber          Number of the error
'             asDescription     Description of the error
'             asSource          Source of the original error (Added 1.00.0001)
'             asLocation        Location of the error
'------------------------------------------------------------------------------------------------
' About     : Sets the current error.
'             If mlErrNumber is already set, it just appends to the location
'================================================================================================

    On Local Error Resume Next

    If mlErrNumber = 0 Then
        mlErrNumber = alNumber
        msErrDescription = asDescription
        If asSource = APP_TITLE Or _
                asSource = asLocation Or _
                asSource = "" Then
            msErrSource = ""
        Else
            'It's someone else's error, record where it came from
            msErrSource = " " & asSource
        End If
        Call gObjCommon.SendToLog("E", mlErrNumber, 1, CLASS_NAME, asLocation, _
                msErrDescription & IIf(msErrSource = "", "", " [Occured in" & msErrSource & "]"))
    End If
    If asLocation <> "" Then
        msErrSource = "." & asLocation & msErrSource
    End If
    
End Sub


The horror?
Appart from the language, why didn't I see this as being repeated? It's in ~50 seperate classes!



Panic, Chaos, Destruction.
My work here is done.

GeneralRe: More an Implimentation Horror Pin
Moreno Airoldi2-Jun-09 23:42
Moreno Airoldi2-Jun-09 23:42 
GeneralI have no name, I don't exist PinPopular
Chris Losinger30-May-09 4:26
professionalChris Losinger30-May-09 4:26 
GeneralRe: I have no name, I don't exist Pin
zlezj31-May-09 11:34
zlezj31-May-09 11:34 
GeneralRe: I have no name, I don't exist Pin
Chris Losinger31-May-09 11:51
professionalChris Losinger31-May-09 11:51 
GeneralRe: I have no name, I don't exist Pin
Thomas Weller31-May-09 20:14
Thomas Weller31-May-09 20:14 
GeneralRe: I have no name, I don't exist [modified] Pin
Chris Losinger1-Jun-09 0:58
professionalChris Losinger1-Jun-09 0:58 
GeneralRe: I have no name, I don't exist Pin
zlezj31-May-09 21:23
zlezj31-May-09 21:23 
GeneralRe: I have no name, I don't exist Pin
johannesnestler3-Jun-09 23:27
johannesnestler3-Jun-09 23:27 
GeneralRe: I have no name, I don't exist Pin
Chris Losinger4-Jun-09 0:57
professionalChris Losinger4-Jun-09 0:57 
GeneralRe: I have no name, I don't exist Pin
supercat94-Jun-09 5:36
supercat94-Jun-09 5:36 
GeneralRe: I have no name, I don't exist Pin
Chris Losinger4-Jun-09 5:51
professionalChris Losinger4-Jun-09 5:51 
GeneralRe: I have no name, I don't exist Pin
supercat94-Jun-09 8:33
supercat94-Jun-09 8:33 
GeneralRe: I have no name, I don't exist Pin
Chris Losinger4-Jun-09 8:43
professionalChris Losinger4-Jun-09 8:43 
GeneralRe: I have no name, I don't exist Pin
Jörgen Sigvardsson12-Jun-09 6:47
Jörgen Sigvardsson12-Jun-09 6:47 
GeneralQuantity FTW! Pin
Brady Kelly28-May-09 22:15
Brady Kelly28-May-09 22:15 
GeneralRe: Quantity FTW! Pin
Tristan Rhodes28-May-09 23:32
Tristan Rhodes28-May-09 23:32 
GeneralRe: Quantity FTW! Pin
Ian Shlasko29-May-09 10:16
Ian Shlasko29-May-09 10:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.