Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. This is the least of...

This is the least of...

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpphpdatabasewinformscom
15 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mel Padden

    ... the horrors in this WinForms app I'm working on...

    		catch (Exception ex)
    		{
    			string errormsg = ex.InnerException.ToString();
    		}
    

    Nice big NullReferenceException for you there mister. Other horrors include : Three separate layers of DB access code, one in VB, on in the Business Logic Layer, and one in a separate assembly (Written in VB!) :doh: :doh:

    Smokie, this is not 'Nam. This is bowling. There are rules. www.geticeberg.com http://melpadden.wordpress.com

    R Offline
    R Offline
    RobCroll
    wrote on last edited by
    #4

    People write this sort of stuff while debugging and forget to remove it. "Ok so what exception is being thrown. I'll write a try catch and see. Problem solved" but you forget to remove the catch statement. Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

    "You get that on the big jobs."

    J R C A 4 Replies Last reply
    0
    • R RobCroll

      People write this sort of stuff while debugging and forget to remove it. "Ok so what exception is being thrown. I'll write a try catch and see. Problem solved" but you forget to remove the catch statement. Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

      "You get that on the big jobs."

      J Offline
      J Offline
      Julien Villers
      wrote on last edited by
      #5

      #if DEBUG
      // Dirty stuff goes here
      #endif

      Not very clean, but somewhat safer.

      'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

      1 Reply Last reply
      0
      • R RobCroll

        People write this sort of stuff while debugging and forget to remove it. "Ok so what exception is being thrown. I'll write a try catch and see. Problem solved" but you forget to remove the catch statement. Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

        "You get that on the big jobs."

        R Offline
        R Offline
        Reiss
        wrote on last edited by
        #6

        without trying to blow my own trumpet - take a look at my tip Preventing stubbed methods from being released[^]

        B 1 Reply Last reply
        0
        • R Reiss

          without trying to blow my own trumpet - take a look at my tip Preventing stubbed methods from being released[^]

          B Offline
          B Offline
          BobJanova
          wrote on last edited by
          #7

          That's pretty nice.

          1 Reply Last reply
          0
          • E ekolis

            Hey, look on the bright side - throwing a NullReferenceException in a catch block is better than just swallowing the original exception without logging or throwing anything else! :P

            C Offline
            C Offline
            cpkilekofp
            wrote on last edited by
            #8

            ekolis wrote:

            Hey, look on the bright side - throwing a NullReferenceException in a catch block is better than just swallowing the original exception without logging or throwing anything else! :P

            :mad: yeah, that's what made "On Error Resume Next" my least favorite phrase ever in a previous time.

            1 Reply Last reply
            0
            • R RobCroll

              People write this sort of stuff while debugging and forget to remove it. "Ok so what exception is being thrown. I'll write a try catch and see. Problem solved" but you forget to remove the catch statement. Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

              "You get that on the big jobs."

              C Offline
              C Offline
              cpkilekofp
              wrote on last edited by
              #9

              Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

              Only by using pre-compilation tags like #Const and #if-then-else. Set your constant to one value (say True) while debugging, then set it to False as you wind down debugging. C has a similiar capability with a few more options, and I used to use this facility to allow trace statements to appear during development and disappear at time of release simply by changing the value of a constant.

              1 Reply Last reply
              0
              • R RobCroll

                People write this sort of stuff while debugging and forget to remove it. "Ok so what exception is being thrown. I'll write a try catch and see. Problem solved" but you forget to remove the catch statement. Does any one know of a nice solution so you can debug but ensure that this sort of rubbish doesn't end up going out the door.

                "You get that on the big jobs."

                A Offline
                A Offline
                Andy Brummer
                wrote on last edited by
                #10

                One developer I worked with used to like

                Assert(DateTime.Now < new DateTime(2011, 10, 1))

                He'd check stuff in and it would break in QA a few days later. :sigh:

                Curvature of the Mind now with 3D

                R B 2 Replies Last reply
                0
                • A Andy Brummer

                  One developer I worked with used to like

                  Assert(DateTime.Now < new DateTime(2011, 10, 1))

                  He'd check stuff in and it would break in QA a few days later. :sigh:

                  Curvature of the Mind now with 3D

                  R Offline
                  R Offline
                  Reiss
                  wrote on last edited by
                  #11

                  OMG - I can't think many coding faux pas worse than that - fingers/hammer combination seems to be all I can recommend - I see you are in the States so hopefully I will never have to work with him

                  1 Reply Last reply
                  0
                  • A Andy Brummer

                    One developer I worked with used to like

                    Assert(DateTime.Now < new DateTime(2011, 10, 1))

                    He'd check stuff in and it would break in QA a few days later. :sigh:

                    Curvature of the Mind now with 3D

                    B Offline
                    B Offline
                    BobJanova
                    wrote on last edited by
                    #12

                    :laugh:

                    1 Reply Last reply
                    0
                    • E ekolis

                      Hey, look on the bright side - throwing a NullReferenceException in a catch block is better than just swallowing the original exception without logging or throwing anything else! :P

                      V Offline
                      V Offline
                      V 0
                      wrote on last edited by
                      #13

                      ekolis wrote:

                      throwing anything else

                      try{
                      //code here
                      }
                      catch(Exception ex){
                      throw new Exception("My crazy message");
                      }

                      This is what you mean right? I've seen people do this, but I always wonder why ? Isn't it heavy doing this?

                      V.

                      E B 2 Replies Last reply
                      0
                      • V V 0

                        ekolis wrote:

                        throwing anything else

                        try{
                        //code here
                        }
                        catch(Exception ex){
                        throw new Exception("My crazy message");
                        }

                        This is what you mean right? I've seen people do this, but I always wonder why ? Isn't it heavy doing this?

                        V.

                        E Offline
                        E Offline
                        ekolis
                        wrote on last edited by
                        #14

                        That is one way to do it, though I was thinking more along the lines of a custom exception, and (if it makes sense in the situation) including the original exception: [code] try { // code here } catch (Exception ex) { throw new MyApplicationCustomException("Oh no! Something went wrong! For more details see the inner exception...", ex); } [/code]

                        1 Reply Last reply
                        0
                        • V V 0

                          ekolis wrote:

                          throwing anything else

                          try{
                          //code here
                          }
                          catch(Exception ex){
                          throw new Exception("My crazy message");
                          }

                          This is what you mean right? I've seen people do this, but I always wonder why ? Isn't it heavy doing this?

                          V.

                          B Offline
                          B Offline
                          BobJanova
                          wrote on last edited by
                          #15

                          My current work project (code base from another company) is full of these, though wrapping in custom exception types and preserving the inner exception. It makes sense when you want to add extra semantic information to the exception because you know the context in which it was called. It doesn't the amount they've done it (and it makes tracking down the actual point of failure a pain). It is 'heavy', yes, but of the order of milliseconds, and if you're using exceptions properly (i.e. they are only thrown in exceptional circumstances) that doesn't matter.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups