A water heater that stops working gives you one useful clue: how it stopped. No hot water at all, hot water that runs out fast, water on the floor, a breaker that will not stay set, and a burner that lights and dies are five different faults. Repair starts by telling them apart.
The faults that come up most
No hot water, gas unit. The pilot or igniter, the thermocouple or flame sensor, the gas valve or the thermostat. On an electric unit the same symptom points at the upper element, a tripped high-limit switch or a failed thermostat.
Water that runs out quickly. A dip tube that has broken off, a lower element that has failed, or a tank full of sediment that has eaten the usable capacity. The first two are parts; the third is a maintenance problem that may already be terminal.
Water on the floor. Location decides everything. Condensation on a cold tank, a weeping drain valve, a loose inlet or outlet union, a failed relief valve, and a rusted shell look similar from standing height and mean very different things.
Breaker tripping. An element that has grounded, wiring damaged by heat or rodents, or moisture in the junction box. This is an electrical fault, and it is not solved by resetting the breaker repeatedly.
Working out whether to repair
Three questions decide it: what failed, how old the unit is, and what condition the tank shell is in. A thermocouple on a four-year-old tank is an easy call. A failed element on a tank with a scaled, corroded bottom is a repair that often precedes a replacement by months.
Manufacturers typically publish an eight to twelve year expected life for tank units, and many failures cluster late in that range. Repair is still reasonable there, as long as the shell and the venting are sound.
Repairs that are not worth attempting
A split tank, a cracked flue collar, a shell that has rusted through, and a gas valve that is obsolete and unavailable. In those cases the money goes further on a replacement, which also brings the installation up to current permit and strapping requirements.
If the unit is dead rather than faulty, start with the emergency page for the shut-off order before anything else.