Debugging Style Notes

A coding note that shows behavior and syntax patterns for cleaner debugging.

Example

function fetchProfile(userId) {
  return fetch(`/api/profile/${userId}`)
    .then((response) => {
      if (!response.ok) {
        throw new Error("Failed to load profile");
      }
      return response.json();
    })
    .catch((error) => {
      console.error("Profile load error:", error);
    });
}

Use clear error messaging and keep returns predictable. When debugging, a simple chain with early failures helps narrow the issue fast.