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. The Lounge
  3. ON ERROR RESUME NEXT

ON ERROR RESUME NEXT

Scheduled Pinned Locked Moved The Lounge
45 Posts 27 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.
  • D DaveAuld

    For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

    Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

    R Offline
    R Offline
    Rob Grainger
    wrote on last edited by
    #35

    I'd say the If..Then..Else statement is pretty clear, amongst many many others. If anything, your example is a little odd, as it really doesn't tell you what it is doing - resume next what? That's not English. (It's also an extremely dodgy technique of error handling, equivalent of enclosing every statement in:

    Exception error;
    try {
    statement;
    }
    catch (Exception ex) {
    error = ex;
    }

    Which just invites people not to bother checking the result. May as well have a statement like

    On Error Keep Calm and Carry On

    "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

    1 Reply Last reply
    0
    • D DaveAuld

      For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

      Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

      J Offline
      J Offline
      Jirajha
      wrote on last edited by
      #36

      I still love plain old C#.

      foreach(var exception in MyExceptionCollection)
      try
      throw exception;
      catch()
      continue;

      H 1 Reply Last reply
      0
      • J Jirajha

        I still love plain old C#.

        foreach(var exception in MyExceptionCollection)
        try
        throw exception;
        catch()
        continue;

        H Offline
        H Offline
        Herbie Mountjoy
        wrote on last edited by
        #37

        The best bit about PERL (in fact the only good bit) is On Error DIE Is that why PERL programmers are becoming scarce? We're philosophical about power outages here. A.C. come, A.C. go.

        1 Reply Last reply
        0
        • D DaveAuld

          For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

          Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

          J Offline
          J Offline
          Jim_Snyder
          wrote on last edited by
          #38

          When I worked at CompuServe, a coworker wrote some code I was running a test harness on for connecting to the portal. His variable "IBHosed" showed up in the exception if the connection wasn't established.

          1 Reply Last reply
          0
          • L Lost User

            The modern version;

            catch
            {
            // all
            }

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            L Offline
            L Offline
            Larry Gibson
            wrote on last edited by
            #39

            catch { // TODO: }

            J 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              The COBOL MOVE statement[^]

              MOVE 50 TO discountPercentage

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

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

              MOVE CORRESPONDING

              Still waiting for one of the "modern languages" to implement that one. (I have to resort to reflection in C#).

              1 Reply Last reply
              0
              • D den2k88

                You're absolutely right about the huge nested ifs, I usually tend to modularize a lot and where multiple checks are involved I use a SEQUENCE of if and a cumulative status, so that it becomes

                bool keep_going = true;
                if (error_cond1) keep_going = false;
                if (keep_going && error_cond2) keep_going = false;
                ...

                It's easier to read and modify, also it's not mandatory to have a single cumulative status. Since I work with stdcalls, VB6 and plain old C code on old compilers (long story short: we can't change.) I can't reliably use exceptions outside the deepest functions and being the VS6 stdlib what it is I don't really need them since it's better to stick to CRT functions, which don't have exceptions. Being VS6 CRT what it is many "safe" functions that use SEH exceptions do not exist so I don't use them either.

                GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani

                F Offline
                F Offline
                firegryphon
                wrote on last edited by
                #41

                I think you could also put in a "goto" instead of setting "keep_going" if you want to break up that nested if architecture. :cool::suss: ;P :laugh:

                1 Reply Last reply
                0
                • Sander RosselS Sander Rossel

                  Like catch (Exception) {} ? I pretty much like my catches, so I'll keep using those thank you :) If I couldn't use lines of code, functions, or libraries whose usage has made me cringe in the past I should really find another job. I've seen things :sigh:

                  Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                  Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                  Regards, Sander

                  S Offline
                  S Offline
                  SeattleC
                  wrote on last edited by
                  #42

                  I think you need

                  catch (void) {}

                  At least in C++ you can throw any type, not just derivations of

                  class Exception

                  1 Reply Last reply
                  0
                  • L Larry Gibson

                    catch { // TODO: }

                    J Offline
                    J Offline
                    jediYL
                    wrote on last edited by
                    #43

                    You've discovered infinite recursion :-D

                    // TODO
                    // catch {
                    // // TODO
                    // }
                    

                    Remain Calm & Continue To Google

                    1 Reply Last reply
                    0
                    • Sander RosselS Sander Rossel

                      Most TrySomething (like TryParse) methods swallow exceptions if you don't check for the return value. The if-statement can be just as harmful. Take those huge nested if-else branches. Impossible to test, impossible to change (without breaking everything). So we replace the if-statements with switch/case-statements, same thing happens. We need to loop through some collection, but it's kind of recursive, and now some programmer uses foreach foreach foreach... (yeah, I've seen it happen). In SQL Server when an exception occurs it's more or less swallowed UNLESS you use try-catch (how many programmers know that?). So I now shouldn't use catch, TryParse, if, switch/case, foreach, and SQL Server :) Well, I agree ON ERROR RESUME NEXT is the most useless of them all :)

                      Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

                      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

                      Regards, Sander

                      O Offline
                      O Offline
                      obermd
                      wrote on last edited by
                      #44

                      If your code is something like this try { statement } catch () {} try { statement } catch () {} ... Then the ON ERROR RESUME NEXT statement makes sense. I actually use it on occasion where I have a short procedure and I want the errors to be consumed and don't care what they are. Doesn't happen often but it does every now and then.

                      1 Reply Last reply
                      0
                      • D DaveAuld

                        For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video :laugh: Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better. And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!

                        Dave Find Me On:Web|Youtube|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                        A Offline
                        A Offline
                        Antonino Porcino
                        wrote on last edited by
                        #45

                        RANDOMIZE TIMER

                        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