# Understanding error messages

An error message feels like a brick wall, but it’s actually a signpost. It tells you **what** went wrong, **where

## Step 1: read the first line

The first line contains the **type** of error and a brief explanation:

```
TypeError: Cannot read properties of undefined (reading 'naam')
```

- `TypeError` = the type of error
- the rest = what exactly happened

## Step 2: read the stack trace

Below the error message is a list of files and line numbers: the **stack trace**. This shows which functions called one another before the error occurred. The top line is where the error occurred. Look for the **first line that points to your own code** (not to `vendor/` or `node_modules/`). That’s usually where the problem lies.

```
#0 app/Http/Controllers/FactuurController.php(42): ...
#1 vendor/laravel/framework/...
```

→ Look in `FactuurController.php`, line 42.

## The most common mistakes

| Error | Language | Usually means |
|---|---|---|
| `TypeError` | JS, Python, PHP | Incorrect value type, e.g. `null` where an object is expected |
| `ReferenceError` | JS | Variable does not exist (typo, incorrect scope) |
| `SyntaxError` | all | Code cannot be read: missing bracket, comma or quotation mark |
| `NullPointerException` | Java | You are using something that is `null` |
| `AttributeError` | Python | Object does not have that attribute or method |
| `KeyError` | Python | Key does not exist in a dictionary |
| `IndexOutOfBoundsException` | Java | Index outside the list |
| `ValueError` | Python | Correct type, incorrect value (`int("abc")`) |
| `ZeroDivisionError` | Python | Division by zero |
| `AssertionError` | Python, tests | A check in a test failed |
| `StackOverflowError` | Java | A function calls itself endlessly |
| `OutOfMemoryError` | Java | Programme is using too much memory |
| `Segmentation fault` | C, native | The programme read memory that did not belong to it |
| `TimeoutError` | all | Something took too long (database, external API) |
| `ConnectionRefused` | all | Nothing is running on that address/port |
| `PermissionDenied` | all | No permissions for a file or folder |
| `Deadlock` | databases | Two processes are waiting for each other |
| CORS error | browser | The server does not permit the request from your site |

**Logical errors** do not trigger any errors: the code runs, but does the wrong thing. That’s where tests come in (see *Testing your app with Pest*).

## Step 3: Reproduce the error

Can you make the error happen every time? If so, please write down:

1. what you did (steps),
2. what you expected,
3. what happened (the full error message).

If you can’t reproduce the issue, it’s often down to timing (see the **concurrency-pitfalls** skill) or differences between your laptop and the server.

## Step 4: Give your AI assistant the full context

Good:

> When I save an invoice, I get this error (full stack trace below). It only happens if the customer has no address. Please investigate the cause before making any changes.

Bad:

> It’s not working – sort it out.

With the **systematic-debugging** skill, your assistant will first identify the cause, rather than guessing and simply dismissing the error message.

## Where can you find mistakes?

- **Laravel** `storage/logs/laravel.log`
- **Browser:** F12 → Console
- **Node:** the terminal where your app is running
- **Production server:** a tool such as Sentry sends you a notification containing the stack trace (see *Logging and monitoring for your app*)

## Need help?

Do the same mistakes keep cropping up? With **AI code review**, I’ll identify the cause and teach your agent how to prevent it in future.

## Skills

- [Systematic Debugging] (/nl/skills/systematic-debugging)
- [Debugging Strategies] (/nl/skills/debugging-strategies)
- [Error Handling Patterns] (/nl/skills/error-handling-patterns)
- [Bug Reproduction Brief] (/nl/skills/bug-reproduction-brief)
- [Troubleshooting Backend Issues] (/nl/skills/troubleshooting-backend)
- [Sentry PHP SDK] (/nl/skills/sentry-php-sdk)

## Related services

- [Beoordeling van AI-code] (/nl/services#service-05)
- [Maatwerk software en webapplicaties] (/nl/services#service-03)

