Finding errors in programs is rarely a simple task. It is not an exact science with clear formulas—it is more of a craft that requires attention, patience, and the right approach. However, there are a number of universal steps that will significantly increase your chances of finding and fixing the problem. Below is a clear and practical guide that will help you work systematically and effectively.

Step 1: Record the problem in a tracker

Before you do anything, write down the error. In the chaos of searching for bugs, it’s easy to miss an important detail or forget what exactly happened. A tracker will allow you to save your train of thought, and if you work in a team, you can delegate the task and hold discussions in one place.

Write down three key points:

  • What the user did.
  • What result was expected.
  • What actually happened.

This will help you understand how to reproduce the problem. If you can’t reproduce the bug, the chances of fixing it drop dramatically.

Step 2: Try to find an error message online

If the program gave you a clear error message, you’re in luck — it’s a ready-made clue. In some cases, it explains the problem directly, in others, it serves as an excellent search query. If there are no messages or they are useless, move on.

Step 3: Determine where the error occurred

If the application crashes, run it under a debugger and see which line of code caused the crash. This does not necessarily mean that the error is located there, but it gives you a starting point and an understanding of its nature.

Step 4: Find where the error originated

The line where the program crashed is just a symptom. The cause is almost always hidden earlier: in incorrect data, an erroneous state, or incorrect logic. Look through the call stack, moving upward.

If the error occurred in a library, the root of the problem is almost always in your code, which passed incorrect data to it.

Step 5: Identify the type of error

Most bugs can be classified into typical categories. Here are the most common ones:

  • Unit error — incorrect index when working with arrays or loops.
  • Race condition — one thread uses data before another has finished working.
  • Incorrect settings — failure due to an incorrect value in the configuration.
  • Unexpected null — accessing an uninitialized variable or an empty value from the database.
  • Incorrect input data — lack of user data validation.
  • Assignment instead of comparison — a classic error in C-family languages.
  • Rounding and type overflow — especially when working with money or large numbers.
  • Working outside the array or buffer — a frequent source of critical vulnerabilities.
  • Errors in logic and formulas — incorrect calculation, incorrect operator, type confusion.
  • Errors in logic and formulas — incorrect calculation, incorrect operator, type confusion.
  • Data mismatch with database types — string too long, unexpected value, etc.
  • Incorrect system state — attempt to perform an action with a closed connection, etc.
  • Environment specifics — something you have that the user does not.
  • If the situation does not fit into these categories or the source is still not found, move on.

Step 6: Use the elimination method

When the source of the error is unknown, it is helpful to disable modules or parts of the code one by one until the bug disappears. This helps to determine which part is causing the problem.

The same can be done with unit tests by isolating individual functions and testing them on the same input data.

Step 7: Increase the detail of the logs

Add more logs to problem areas. Do this gradually, module by module. After each step, analyze the log and look for clues that will lead you to the source of the error.

If the standard logs are insufficient, it is worth using third-party tools that record more details.

Step 8: Rule out the influence of hardware or environment

Sometimes the bug is not caused by the code at all. Try replacing the hardware, checking the memory, repeating the execution on another server or under a different OS. Sometimes even unstable power supply or network equipment can cause problems.

If the error occurs the same way everywhere, it is definitely in the code.

Step 9: Pay attention to patterns

  • Repeating conditions are valuable clues.
  • Does the error always occur at the same time?
  • Does it occur alongside another event, even a strange one?
  • Does it affect users in a specific region?
  • Does it occur during peak loads?
  • Any small detail can be a clue.

Step 10: Ask for help

If you’ve done everything you can but still can’t find the cause, it’s time to contact the technical support team for the framework, library, or database. However, it’s important to provide a detailed description of the problem and the steps to reproduce it — without this, they simply won’t be able to help you.