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. Exception handling

Exception handling

Scheduled Pinned Locked Moved The Weird and The Wonderful
debugginghelpquestion
19 Posts 12 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.
  • Sander RosselS Sander Rossel

    Example of what I have seen...

    Try
    ' This code starts up a form.
    Catch oE as Exception
    ' Do nothing. If the form does not start you'll notice soon enough.
    End Try

    The comment in the Catch is taken almost literally from the code! I found it when I pasted a new form in the application and it did not start up. Well, at least the Catch was right in that I noticed soon enough :laugh: Don't really know what oE is. I guess ex was not obvious enough ;P Even worse is when I am forced to use company classes that catch and handle errors without giving them back. They usually log an error, end of story. How am I supposed to notify the user about any errors if my classes do not give me back an Exception? :confused: The worst part is that the application usually lacks any form design making class A depend on B and C, B on C and A, and C on A and B. So when I change a class (like removing unnecessary Catch blocks or rethrowing an Exception)... Well, who knows what might happen :(

    It's an OO world.

    _ Offline
    _ Offline
    _Erik_
    wrote on last edited by
    #5

    An idea for "oE" might be: "obscure Exception". The lowercase "o" is to keep it as obscure as possible. :laugh:

    G Sander RosselS 2 Replies Last reply
    0
    • _ _Erik_

      An idea for "oE" might be: "obscure Exception". The lowercase "o" is to keep it as obscure as possible. :laugh:

      G Offline
      G Offline
      GenJerDan
      wrote on last edited by
      #6

      More likely, "obvious Exception", since If the form does not start you'll notice soon enough. Obviously.

      There is water at the bottom of the ocean. My Mu[sic] My Films My Windows Programs, etc.

      1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        Example of what I have seen...

        Try
        ' This code starts up a form.
        Catch oE as Exception
        ' Do nothing. If the form does not start you'll notice soon enough.
        End Try

        The comment in the Catch is taken almost literally from the code! I found it when I pasted a new form in the application and it did not start up. Well, at least the Catch was right in that I noticed soon enough :laugh: Don't really know what oE is. I guess ex was not obvious enough ;P Even worse is when I am forced to use company classes that catch and handle errors without giving them back. They usually log an error, end of story. How am I supposed to notify the user about any errors if my classes do not give me back an Exception? :confused: The worst part is that the application usually lacks any form design making class A depend on B and C, B on C and A, and C on A and B. So when I change a class (like removing unnecessary Catch blocks or rethrowing an Exception)... Well, who knows what might happen :(

        It's an OO world.

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #7

        Naerling wrote:

        Don't really know what oE is

        That's obvious Enough, isn't it?

        1 Reply Last reply
        0
        • _ _Erik_

          An idea for "oE" might be: "obscure Exception". The lowercase "o" is to keep it as obscure as possible. :laugh:

          Sander RosselS Offline
          Sander RosselS Offline
          Sander Rossel
          wrote on last edited by
          #8

          The Dutch (yes, I'm from the Netherlands) word for 'unknown' is 'Onbekend' and the Dutch word for 'unexpected' is 'Onverwacht'... So maybe I should have translated oE to uE? :^) I love all the guesses coming in though, keep them coming! :laugh:

          It's an OO world.

          1 Reply Last reply
          0
          • Sander RosselS Sander Rossel

            Example of what I have seen...

            Try
            ' This code starts up a form.
            Catch oE as Exception
            ' Do nothing. If the form does not start you'll notice soon enough.
            End Try

            The comment in the Catch is taken almost literally from the code! I found it when I pasted a new form in the application and it did not start up. Well, at least the Catch was right in that I noticed soon enough :laugh: Don't really know what oE is. I guess ex was not obvious enough ;P Even worse is when I am forced to use company classes that catch and handle errors without giving them back. They usually log an error, end of story. How am I supposed to notify the user about any errors if my classes do not give me back an Exception? :confused: The worst part is that the application usually lacks any form design making class A depend on B and C, B on C and A, and C on A and B. So when I change a class (like removing unnecessary Catch blocks or rethrowing an Exception)... Well, who knows what might happen :(

            It's an OO world.

            D Offline
            D Offline
            Dalek Dave
            wrote on last edited by
            #9

            That's excellent.

            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

            1 Reply Last reply
            0
            • T Thallian

              Why do so many think that try - catch blocks are just here to stop you from seeing runtime errors? It is a plain nightmare to debug a project which has code like this sprinkled all over the place. (Note: I removed some confidental information from the code)

              try
              {
              if (SomeConstant != "")
              {
              this.comboBox.SelectedItem = this.comboBox.Items[this.comboBox.Items.IndexOf(SomeConstant)];
              }
              }
              catch { }

              Or one of my favourites:

              protected override bool Exists()
              {
              bool returnValue = false;
              try
              {
              // guess what happens when the webservice access throws an exception...
              product = GetProductOverWebservice()

                if (product != null && product.product\_id == m\_RecordID.ToString())
                {
                  \_product = productinfo;
                  returnValue = true;
                }
              }
              catch (Exception ex)
              {
                //great, just comment the only thing that could tell at least that an error occured
                //base.DebugWrite("\\tError: " + ex.ToString(), MODUL\_NAME);
              }
              return returnValue;
              

              }

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

              It once took me 2 days! to track down a bug because someone had decided to swallowed the exception catch { }. The problem is some programmers just don't get it. The best article I've ever read regarding exception handling is Exception Handling Best Practices and it's on CodeProject.

              "You get that on the big jobs."

              Sander RosselS Q 2 Replies Last reply
              0
              • R RobCroll

                It once took me 2 days! to track down a bug because someone had decided to swallowed the exception catch { }. The problem is some programmers just don't get it. The best article I've ever read regarding exception handling is Exception Handling Best Practices and it's on CodeProject.

                "You get that on the big jobs."

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #11

                Two days to track down an exception :wtf: There is an option in Visual Studio that takes you to the specific line of code where the exception occured as soon as it occurs (so when in debug mode). Not sure where to find it, but my keyboard shortcut is ctrl + alt + e (but that may vary per country or VS) :thumbsup: Of course I have no idea if other programs have it too. Excellent article btw! :thumbsup:

                It's an OO world.

                R 1 Reply Last reply
                0
                • Sander RosselS Sander Rossel

                  Two days to track down an exception :wtf: There is an option in Visual Studio that takes you to the specific line of code where the exception occured as soon as it occurs (so when in debug mode). Not sure where to find it, but my keyboard shortcut is ctrl + alt + e (but that may vary per country or VS) :thumbsup: Of course I have no idea if other programs have it too. Excellent article btw! :thumbsup:

                  It's an OO world.

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

                  Hi Naerling, The problem is you may not be aware that it is an exception that is the problem. In this case it smelt like business logic because no exceptions where being thrown or logged. The Exception window is a great tool. It can be found in the menu bar under Debug, Exceptions...

                  "You get that on the big jobs."

                  Sander RosselS 1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    Example of what I have seen...

                    Try
                    ' This code starts up a form.
                    Catch oE as Exception
                    ' Do nothing. If the form does not start you'll notice soon enough.
                    End Try

                    The comment in the Catch is taken almost literally from the code! I found it when I pasted a new form in the application and it did not start up. Well, at least the Catch was right in that I noticed soon enough :laugh: Don't really know what oE is. I guess ex was not obvious enough ;P Even worse is when I am forced to use company classes that catch and handle errors without giving them back. They usually log an error, end of story. How am I supposed to notify the user about any errors if my classes do not give me back an Exception? :confused: The worst part is that the application usually lacks any form design making class A depend on B and C, B on C and A, and C on A and B. So when I change a class (like removing unnecessary Catch blocks or rethrowing an Exception)... Well, who knows what might happen :(

                    It's an OO world.

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #13

                    Naerling wrote:

                    Don't really know what oE is

                    I guess it means "objectException", in an extra nasty form of hungarian notation.

                    List of common misconceptions

                    L 1 Reply Last reply
                    0
                    • R RobCroll

                      Hi Naerling, The problem is you may not be aware that it is an exception that is the problem. In this case it smelt like business logic because no exceptions where being thrown or logged. The Exception window is a great tool. It can be found in the menu bar under Debug, Exceptions...

                      "You get that on the big jobs."

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #14

                      Actually, the catch that said 'Do nothing, if the form does not start you will know soon enough' (see a previous post) did nothing because some forms were started and disposed immediatly, or gave the user the option to end it while it was still loading. This, of course, gave an exception. But because it was meant to behave like that the programmer did not want to do anything with the exception... So when I fixed it by showing a messagebox and logging the exception I actually got told to undo my changes because 'the business logic was designed that way'! How about that for business logic? ;P

                      It's an OO world.

                      1 Reply Last reply
                      0
                      • Sander RosselS Sander Rossel

                        Example of what I have seen...

                        Try
                        ' This code starts up a form.
                        Catch oE as Exception
                        ' Do nothing. If the form does not start you'll notice soon enough.
                        End Try

                        The comment in the Catch is taken almost literally from the code! I found it when I pasted a new form in the application and it did not start up. Well, at least the Catch was right in that I noticed soon enough :laugh: Don't really know what oE is. I guess ex was not obvious enough ;P Even worse is when I am forced to use company classes that catch and handle errors without giving them back. They usually log an error, end of story. How am I supposed to notify the user about any errors if my classes do not give me back an Exception? :confused: The worst part is that the application usually lacks any form design making class A depend on B and C, B on C and A, and C on A and B. So when I change a class (like removing unnecessary Catch blocks or rethrowing an Exception)... Well, who knows what might happen :(

                        It's an OO world.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #15

                        Awesome.

                        Regards, Koushik. Most people never run far enough on their first wind to find out if they've got a second. Give your dreams all you've got and you'll be amazed at the energy that comes out of you.

                        1 Reply Last reply
                        0
                        • J Jorgen Andersson

                          Naerling wrote:

                          Don't really know what oE is

                          I guess it means "objectException", in an extra nasty form of hungarian notation.

                          List of common misconceptions

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #16

                          :laugh:

                          Regards, Koushik. Most people never run far enough on their first wind to find out if they've got a second. Give your dreams all you've got and you'll be amazed at the energy that comes out of you.

                          1 Reply Last reply
                          0
                          • R RobCroll

                            It once took me 2 days! to track down a bug because someone had decided to swallowed the exception catch { }. The problem is some programmers just don't get it. The best article I've ever read regarding exception handling is Exception Handling Best Practices and it's on CodeProject.

                            "You get that on the big jobs."

                            Q Offline
                            Q Offline
                            Quirkafleeg
                            wrote on last edited by
                            #17

                            RobCroll wrote:

                            The problem is some programmers just don't get it.

                            Unfortunately, it's usually the customers who don't get it. Our code is full of this "non-specific" error handling - not because we are bad programmers, but because customers don't want to see error messages (we've had complaints, such as "It's telling me that the socket has refused the connection! I don't want to see it!"). To me, that is stupid - I'd rather see a problem instead of sitting around wondering why something isn't working. On the other hand, we work a lot with real-time data, so customers don't want it constantly stopped by dialog boxes intimating that their system is badly set up (as it usually is)! At least all our exceptions are logged - a small scrap of comfort for us.

                            R 1 Reply Last reply
                            0
                            • Q Quirkafleeg

                              RobCroll wrote:

                              The problem is some programmers just don't get it.

                              Unfortunately, it's usually the customers who don't get it. Our code is full of this "non-specific" error handling - not because we are bad programmers, but because customers don't want to see error messages (we've had complaints, such as "It's telling me that the socket has refused the connection! I don't want to see it!"). To me, that is stupid - I'd rather see a problem instead of sitting around wondering why something isn't working. On the other hand, we work a lot with real-time data, so customers don't want it constantly stopped by dialog boxes intimating that their system is badly set up (as it usually is)! At least all our exceptions are logged - a small scrap of comfort for us.

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

                              Some of the exceptions I get I don't understand! So what chance does a user have. They just don't understand the message. I like to encapsulate the error message in the business layer and throw a more user friendly error message to the presentation layer “Could not save customer information because computer networks are down.”. Users understand that. They have no idea of what a TCP/IP socket is but they understand that networks aren't always working. That's the problem. It's not that there is a problem but the the message is meaningless. They don't understand the message. So whether you are implementing MVC or MVVM or whatever, at some stage you need to consider the message the user gets. Once they understand the problem, it's all cool... “see your Systems Administrator”. Now who the hell is that? :) BTW that small scrap would be a life saver.

                              "You get that on the big jobs."

                              1 Reply Last reply
                              0
                              • T Thallian

                                Why do so many think that try - catch blocks are just here to stop you from seeing runtime errors? It is a plain nightmare to debug a project which has code like this sprinkled all over the place. (Note: I removed some confidental information from the code)

                                try
                                {
                                if (SomeConstant != "")
                                {
                                this.comboBox.SelectedItem = this.comboBox.Items[this.comboBox.Items.IndexOf(SomeConstant)];
                                }
                                }
                                catch { }

                                Or one of my favourites:

                                protected override bool Exists()
                                {
                                bool returnValue = false;
                                try
                                {
                                // guess what happens when the webservice access throws an exception...
                                product = GetProductOverWebservice()

                                  if (product != null && product.product\_id == m\_RecordID.ToString())
                                  {
                                    \_product = productinfo;
                                    returnValue = true;
                                  }
                                }
                                catch (Exception ex)
                                {
                                  //great, just comment the only thing that could tell at least that an error occured
                                  //base.DebugWrite("\\tError: " + ex.ToString(), MODUL\_NAME);
                                }
                                return returnValue;
                                

                                }

                                M Offline
                                M Offline
                                Member 96
                                wrote on last edited by
                                #19

                                I guess that's why they invented the option in the debugger to break on any exception being thrown. :)


                                There is no failure only feedback

                                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