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. Web Development
  3. ASP.NET
  4. Extending Try Catch

Extending Try Catch

Scheduled Pinned Locked Moved ASP.NET
helpcareer
4 Posts 3 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.
  • W Offline
    W Offline
    wEb GuRu
    wrote on last edited by
    #1

    Hi Developers, I am using a group of statements in Try Catch Block. When an Error occured at any line of "Try Block" control goes to "Catch Block" and skip the execution of lines coming after Error Line. Now what I want is that "Program should start execution from line after the Error Line(Where error occurs)". I think there is some statement like Resume next is used in this case but not sure. Thanks in advance Lets work it Out.........!

    J 1 Reply Last reply
    0
    • W wEb GuRu

      Hi Developers, I am using a group of statements in Try Catch Block. When an Error occured at any line of "Try Block" control goes to "Catch Block" and skip the execution of lines coming after Error Line. Now what I want is that "Program should start execution from line after the Error Line(Where error occurs)". I think there is some statement like Resume next is used in this case but not sure. Thanks in advance Lets work it Out.........!

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      the only way to do this is to wrap a try..catch around each line individually. You can also nest try..catch blocks inside a master try..catch block to handle the real critical errors eg/ try try ' something error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw try ' something else error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw catch MyCriticalException ex ' handle critical exception

      W G 2 Replies Last reply
      0
      • J J4amieC

        the only way to do this is to wrap a try..catch around each line individually. You can also nest try..catch blocks inside a master try..catch block to handle the real critical errors eg/ try try ' something error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw try ' something else error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw catch MyCriticalException ex ' handle critical exception

        W Offline
        W Offline
        wEb GuRu
        wrote on last edited by
        #3

        Hi J4amieC Thanks a lot for your help. Would U b so kind to tell me a little about the Flow of the code u sent to me. Thanks Lets work it Out.........!

        1 Reply Last reply
        0
        • J J4amieC

          the only way to do this is to wrap a try..catch around each line individually. You can also nest try..catch blocks inside a master try..catch block to handle the real critical errors eg/ try try ' something error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw try ' something else error-prone catch MySpecificException ex ' do something catch MyCriticalException ex throw catch MyCriticalException ex ' handle critical exception

          G Offline
          G Offline
          gyokusei
          wrote on last edited by
          #4

          The flow of try catch block is when your code in try block occurs an error, it will do something in catch block. After that it will do something after catch block. So that:

          SqlConnection connection = new SqlConnection( "ConnectionString" );
          SqlCommand cmd = new SqlCommand( "CommandText", connection );
          try {
          connection.Open();
          cmd.ExecuteNoneQuery();
          }
          catch {
          // do something
          }

          now you put each line in try block in try catch block like that:

          try {

          try {
              connection.Open();
          } catch {
              // do something
          }
          
          try {
               cmd.ExecuteNoneQuery();
          } catch {
              // do something
          }
          

          }
          catch {
          // do something
          }

          Do you understand now?

          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