# Stack Trace for Exceptions

**URL:** <https://discourse.processing.org/t/stack-trace-for-exceptions/46569>\
**Category:** Processing\
**Created:** [June 17, 2025, 4:20pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569 "2025-06-17T16:20:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![plammich](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@plammich](https://discourse.processing.org/u/plammich)\
**Post date:** [June 17, 2025, 4:20pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/1 "2025-06-17T16:20:05Z")

</div>

How to get a stack-trace if the program throws an exception (or any information pointing to the position in the program from where the exception was thrown?)

Example (a typical beginner’s mistake):

```auto
PVector [] vs = new PVector [10];

for (int i=0;i<vs.length;++i) 
  vs[i].set(0,0);

```

When running this in processing, all it does is displaying a red NullPointerException message. I cannot see any way to find out where in the program this was thrown. (Ideally, I would like to see a stack trace). If this is not possible, what is the suggested approach in Processing to debugging (unexpected) exceptions, in particular if the programs get bigger?

(processing 4.4.4 on Ubuntu 24.04, just in case that’s a known platform issue)

– Peter Lammich

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 17, 2025, 4:55pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/2 "2025-06-17T16:55:31Z")

</div>

Hello @plammich ,

I am using W10.

Processing 3.5.4 will highlight the line:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/c/0c76f21c75742a229f7ce651f7c9918fe74d39fe.png)

Processing 4.4.4 only shows this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/c/2c0b89e4b00e6feba9c4eb18345824cfd882d5e8.png)

I have observed that error checking does not seem to work in latest versions.

There may be an issue regarding this here:  
_[GitHub · Where software is built](https://github.com/processing/processing4/issues)_

PVectors need to be initailized first:

```auto
for (int i = 0; i < vs.length; ++i) 
  {
  vs[i] = new PVector(0, 0); // Initialize each PVector
  }

for (int i=0;i<vs.length;++i)
  {
  vs[i].set(0,0);
  }

```

`:)`

---

<div class="post-metadata">

**Author:** ![plammich](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@plammich](https://discourse.processing.org/u/plammich)\
**Post date:** [June 17, 2025, 5:27pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/3 "2025-06-17T17:27:46Z")

</div>

Interesting. So a bug in processing 4.4.4? (One that makes it basically unusable for any semi-serious use). I’ll check if I find it in the issue tracker, and report it there otherwise.

btw: of course PVectors need tio be initialized, I just posted an example for a typical (beginner’s) mistake, that becomes really hard to debug without exception stack trace.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 17, 2025, 6:59pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/4 "2025-06-17T18:59:25Z")

</div>

> [@plammich](#):
>
> So a bug in processing 4.4.4?

Just an observation for now.

@stefterv Can you comment on this? Thanks in advance.

> [@plammich](#):
>
> btw: of course PVectors need tio be initialized, I just posted an example for a typical (beginner’s) mistake, that becomes really hard to debug without exception stack trace.

I sometimes share for the larger community; it may not be obvious to someone new here and perusing the topics.

I generally temper my enthusiasm with restraint but other times get immersed in a topic.

I will stop now… `:)`

---

<div class="post-metadata">

**Author:** ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)\
**Post date:** [June 17, 2025, 7:04pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/5 "2025-06-17T19:04:57Z")

</div>

Hi @glv thank you for the tag! Could you quickly check if this is new in the 4.4.x versions by running 4.3?

I would need to know if it is a regression since those versions, then we can fix it. Otherwise it might be a deeper issue needing more attention.

---

<div class="post-metadata">

**Author:** ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)\
**Post date:** [June 17, 2025, 7:42pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/6 "2025-06-17T19:42:20Z")

</div>

Okay tested it right now, seems to be a regression in 4.4.x. Not sure what causes it but at least gives me an idea on where to look.

---

<div class="post-metadata">

**Author:** ![stefterv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stefterv/32/21678_2.png) [@stefterv](https://discourse.processing.org/u/stefterv)\
**Post date:** [June 17, 2025, 8:20pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/7 "2025-06-17T20:20:28Z")

</div>

Tracked down the underlying issue that is causing this, so at least it is understood why this is happening

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 25, 2025, 6:20pm UTC](https://discourse.processing.org/t/stack-trace-for-exceptions/46569/8 "2025-06-25T18:20:35Z")

</div>

Sharing for those coming across this topic.

This is a work in progress:

> <https://github.com/processing/processing4/issues/1153>
>
> \### Most appropriate sub-area of Processing 4?
> 
> PDE
> 
> \### Processing version
> 
> 4.4….4
> 
> \### Operating system
> 
> Ubuntu 24.04, Windows 10
> 
> \### Bug description
> 
> The location of an exception (e.g. NullPointerException) is not highlighted, nor is a stack trace printed. The only information printed is a red NullPointerException message at the bottom. There is no obvious way how to find out where this was thrown.
> 
> This seems to be a regression to earlier 3.x versions, where the line of the thrower would be at least highlighted. 
> 
> 
> 
> \### Steps to reproduce this
> 
> "1. open the below snippet in PDE
> 
> 2. run the snippet
> 
> 3. observe that the error message (NullPointerException) is not linked to any position in the code, nor is any position in the code highlighted, nor is a stack-trace or similar printed anywhere"
> 
> 
> \### snippet
> 
> \`\`\`
> PVector \[\] vs = new PVector\[10\];
> for (int i=0;i\<vs.length;++i)
> vs\[i\].set(0,0); // \<-- this position should be contained in the error message
> 
> \`\`\`
> 
> 
> \### Additional context
> 
> real showstopper when trying to debug any bigger program in PDE!
> 
> \### Would you like to work on the issue?
> 
> No, I’m just reporting the issue
