Great work!

XP to next level

BugEater

Error Code Pattern Analysis

Learning Objectives

By the end of this lesson you will be able to:

  • Recognize common error code patterns for mathematical and validation failures
  • Correlate specific error codes with specific root causes
  • Produce a bug report that references both the observed error code and the inferred cause

The Error Code as a Clue

Every error has a code. Sometimes it's an HTTP status code. Sometimes it's an application-specific error code in the response body. Sometimes it's a database error code buried in the stack trace.

Each of these tells a different part of the story.

Common Error Code Patterns in Mathematical Systems

Pattern 1: Division by Zero

  • App layer: ArithmeticException: / by zero (Java)
  • DB layer: PSQLException: ERROR: division by zero (PostgreSQL)
  • Float result: No exception — result is Infinity or NaN
  • Tester action: The float case is the most dangerous — no error code, wrong result

Pattern 2: Integer Overflow

  • App layer: Silent wrap-around (no code), or ArithmeticException: integer overflow if using Math.addExact()
  • DB layer: PSQLException: ERROR: integer out of range (PostgreSQL 22003)
  • Tester action: Both need a bug report; DB-layer error means the app didn't validate

Pattern 3: Invalid Input Format

  • App layer: NumberFormatException: For input string: "abc" (Java)
  • DB layer: PSQLException: invalid input syntax for type integer: "abc"
  • Tester action: HTTP 500 with NumberFormatException = app didn't validate input type

Pattern 4: Null Value in Calculation

  • App layer: NullPointerException at a calculation line
  • DB layer: PSQLException: null value in column violates not-null constraint
  • Tester action: Input not validated before use; null propagated to arithmetic

The Pattern Recognition Table

Use this table when analyzing error responses:

Error Code / Message Root Cause Layer Fix
ArithmeticException: / by zero Divisor not validated App Validate divisor ≠ 0 before divide
integer out of range Value too large for INT DB Validate range or use BIGINT
NumberFormatException Non-numeric string used in math App Parse/validate input type
NullPointerException in calculation Null not checked App Add null check
numeric field overflow Decimal precision exceeded DB Use larger NUMERIC type

Building Your Error Code Library

Over time, you'll build a personal library of error codes and their meanings. Some are universal (Java exceptions, PostgreSQL codes), some are application-specific.

When you encounter a new error code you don't recognize:

  1. Google it: "PSQLException 22003" tells you immediately it's integer overflow
  2. Note it in your personal reference
  3. Look for the same code in future test sessions — patterns recur

Writing the Diagnostic Bug Report

Title: Calculator returns 500 "integer out of range" for large input values

HTTP Status: 500
Response:
{
  "error": "DataAccessException",
  "cause": "ERROR: integer out of range",
  "detail": "Value 3000000000 is out of range for type integer"
}

Root Cause Analysis:
- Error is PSQLException "integer out of range" = PostgreSQL error code 22003
- This is a DB-layer error: the value passed to the INSERT statement exceeded INT range
- Application layer did not validate input before passing to database
- The column likely uses PostgreSQL INTEGER (max 2,147,483,647), but input is 3,000,000,000

Recommended Fix: Add server-side validation that rejects values > 2,147,483,647, 
OR change column type to BIGINT.

Pro Tip: A bug report that includes both the exact error code AND the root cause analysis is not just "better" — it's the difference between a fix taking 10 minutes vs. 2 hours. Developers appreciate the diagnosis.

Key Takeaways

  • Error codes tell a specific story — learn to read them
  • 22003 = PostgreSQL integer overflow; ArithmeticException = Java app layer
  • Build your personal error code reference over time
  • Include error code + layer identification + root cause analysis in every bug report

Quiz

An error response contains "PSQLException: ERROR: integer out of range". What does this tell a tester?

Which error class indicates the failure was in Java application code rather than the database?

Why does building a personal error code library help testers be more effective?

What should a complete technical bug report include when you identify both the error code and root cause?