Processing project started in CMD - error handling

I just start bat file, and want to open some my .pde project, and run it…
It works, but… When i have some syntax error in the code, it will only close
cmd…

I want to get the error, where is it ? What is it ? What is the type of error ? Or somethink…

processing-java --sketch=%cd% --output=%cd%/output" --force --run

Can i somehow print out error in the cmd line ? Or can it create some log files with error ?

Thanks.

You could catch the error through

void setup() {
  try {
     // Whatever your code in setup is
  }
  catch (Exception err) {
    println(err);
    exit();
  }
}

void draw() {
  try {
     // Whatever your code in draw is
  }
  catch (Exception err) {
    println(err);
    exit();
  }
}

try … catch blocks.

EDIT: Added semicolons

1 Like

Hmmm, good, but, when i will have some Syntax error it doesnt show it…

It works well, but, why it cant save to “error-chech.log” file ? … the output of CMD console

cd C:\Users\ASROCK\Documents\processing-3.3.6\
start cmd.exe @cmd /k "@echo off&color 0a&processing-java --sketch=C:\Users\ASROCK\Desktop\loader\output_files\main --output=C:\Users\ASROCK\Desktop\loader\output_files\main\output-compile --force --run > C:\Users\ASROCK\Desktop\loader\error-check.log"
exit

The output of the CMD console, it creates log file, but it doesnt save the console lines…
image

I could think of three options:

  1. The corresponding log file is saved in your user folder, there starts usually a new instance of cmd
  2. The log file is saved in %windir%\System32 because there is cmd.exe located
  3. Whyever piping doesn’t work with parameter /k, an approach to save the log file directly in the application:
PrintWriter o;

void setup() {
  o = createWriter("C:/Users/yoursuperhotusername/Desktop/loader/error-check.log");
  try {
     // Whatever your code in setup is
  }
  catch (Exception err) {
    o.println(err);
    o.flush();
    o.close();
    exit();
  }
}

void draw() {
  try {
     // Whatever your code in draw is
  }
  catch (Exception err) {
    o.println(err);
    o.flush();
    o.close();
    exit();
  }
}

(Sorry, forgot the semicolon before because working in Python)

EDIT: Your little bat script should add before executing the program:

mkdir C:\superhotsuperhot\Desktop\loader

… I mean … it cant see if the syntaxes are correct… There is some way, how to put cmd lines to a text file, i want it for my extern editor, where i want to see on wich line is error on wich filename…

image

May you want to take a look at this (https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html)?
Throwables are serializable, and so you could get the message and parse it.
What editor do you use? You could parse after the expecting, '' and look at the double points. The first number (usually) declares the line, the second number the character.

maybe good way, but when is the some syntax error in the cond, it wont to compile it …