Situation

You have two similar pieces of code. In one of them the failure occurs, in the other it doesn't.

Approach

From each piece of code, print pertinent information about program state and parameter values. Diff the printouts. You might find a Suspicious value.

Example

You have a Ruby on Rails controller. When it receives a GET request, it responds with 202 OK. When it receives a POST request, it responds with 401 Unauthorized. Both routes have a before_action that requires the user to log in.

→ Print the request.env in both cases. You might find that when processing the POST request, rack.session is a NullSession, which is your Suspicious value.

When there is nothing to print

Then list the differences that you see. For example, I had a problem where exceptions were not being caught when thrown from one place, but they were caught when thrown from all other places. There was no clear circumstantial information to print. Still, I wondered what the difference between those pieces of code was.

The first thing that came to mind was this: The uncaught exception was thrown one level up the stack from the catch call. The caught exceptions were thrown two or more levels up the stack from the catch call. I dismissed this, because clearly it shouldn't matter how many calls there are between a throw and a catch.

But I had nothing else to go on, so I thought about it a little more… and realized that the uncaught exception was thrown in the initial synchronous part of a promise chain (JS) and the caught exceptions were thrown in the asynchronous part:

synchronous_start_returning_promise().then(…).catch(…)

Promise.catch don't catch nuttin' synkernous.