Can you skip to view more errors?

Is there a way to look all the errors in your code at once by skipping errors?

Answers

  • THey are in the direct window below

    Click in it and use ctrl-a and ctrl-c to copy the entire content

    Copy to your editor

    When writing a sketch though write it so that you save and run it often so that you can correct the errors immediately

    Like run it every two minutes

  • my pde (macos, p3) shows only the first syntax error, in the red bar between the editor window and the console. i think that's what he means, he'd like to see more.

  • Koogs is correct. How do I do that? Anyone?

  • Are you talking about compiler errors or runtime errors?

    If you're talking about complier errors, then they should all be shown. For example:

    void setup(){
     bad
    }
    
    void draw(){
     bad 
    }
    

    In my editor, both bad lines are shown with a red underline. This is invalid syntax and is a compiler error.

    If you're talking about runtime errors, then only the first one will be shown. For example:

    String test = null;
    
    void setup(){
     println(test.length());
    }
    
    void draw(){
     println(test.length());
    }
    

    This is valid syntax and will compile and run. But when you run it, you'll get a NullPointerException because the test variable is null. But only the first error is shown. This is because the code stops running at this point, so no more errors are hit.

    You can catch the exception and do whatever handling you want. For example:

    String test = null;
    
    void setup(){
     try{
       println(test.length());
     }catch(NullPointerException npe){
      npe.printStackTrace(); 
     }
    }
    
    void draw(){
     println(test.length());
    }
    

    Now the first NPE is caught and we can do whatever we want with it. In this case I just print the stack trace. In this case, the code will continue and we'll see the second NPE. We could also wrap this one in a try-catch block.

    Shameless self-promotion: I wrote a tutorial on error handling here. That's more geared towards Java than Processing, but all of the principles apply.

  • edited January 2018

    then they should all be shown

    nope, i see nothing in the window.

    if i hit run i see one syntax error in the bit between the editor and the console. (on linux now, on macos earlier)

  • edited January 2018

    To understand what's going on, we need to understand the difference between compiler errors and runtime errors. The code with two bad lines in it will not compile so it doesn't make sense to try to run it.

    In Processing, compiler errors are shown as red underlines in your code. All of them will be marked:

    compiler errors

    If you try to run code that contains compiler errors, then it will fail when it gets to the first error. But you shouldn't even try to run code that contains compiler errors.

  • In Processing, compiler errors are shown as red underlines in your code. All of them will be marked:

    no, look at my picture. where are the red underlines?

  • I've looked at your picture. Can you look at mine? What version of Processing are you using? Do you have Continuously check for errors enabled in your settings?

  • yes, it's a preference. that's the important information. it's no use telling the OP that they are underlined in red when they aren't underlined in red FOR HIM. and the compile vs runtime stuff is irrelevant until he can see what you're seeing.

    (and me posting my pictures was an attempt to back up the OP, to point out that that option is an option, that's what i was trying to get at)

    ((sorry if that's a bit obtuse))

  • Hmm, the thing is that I don't think I've ever changed this setting. My guess is that it's on by default.

    To be fair neither one of us knows whether the OP is talking about compiler errors (if so the answer is to enable this setting, which may or may not be enabled by default) or runtime errors (if so the answer is to use try-catch blocks).

Sign In or Register to comment.