# Processing project started in CMD - error handling

**URL:** <https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930>\
**Category:** Processing\
**Created:** [February 19, 2020, 12:43pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930 "2020-02-19T12:43:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [February 19, 2020, 12:43pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/1 "2020-02-19T12:43:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [February 19, 2020, 1:39pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/2 "2020-02-19T13:39:50Z")

</div>

You could catch the error through

```auto
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

---

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [February 19, 2020, 2:12pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/3 "2020-02-19T14:12:39Z")

</div>

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

```auto
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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3a854294f37e8f9bb7aec6fe770f3cc0e0e3de2f.png)

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [February 19, 2020, 2:26pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/4 "2020-02-19T14:26:25Z")

</div>

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:

```auto
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:

```auto
mkdir C:\superhotsuperhot\Desktop\loader

```

---

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [February 19, 2020, 2:41pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/5 "2020-02-19T14:41:21Z")

</div>

… 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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/50ac3ca239380822cc5a6998737e84c839f3c20d.png)

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [February 19, 2020, 2:50pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/6 "2020-02-19T14:50:32Z")

</div>

May you want to take a look at this ([https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html](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.

---

<div class="post-metadata">

**Author:** ![GeorgeJava](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/georgejava/32/7646_2.png) [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Post date:** [February 19, 2020, 2:55pm UTC](https://discourse.processing.org/t/processing-project-started-in-cmd-error-handling/17930/7 "2020-02-19T14:55:09Z")

</div>

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