I have a relatively old house, built in the 1950s. I am slowly updating it to have smart switches etc., but the existing electrical wiring is fairly haphazard. Just yesterday I replaced a dimmer switch and found that the white wire pigtail in the box was in fact hooked up to hot, not neutral. Fortunately when I turned on the circuit it tripped the GFCI before doing any damage but I wonder if there's a better way to avoid this in the future.
Currently I just turn off the circuit at the breaker and verify there's nothing live in the box with a non-contact tester (and then an insulated screwdriver, just to be sure). Should I be pulling the wires out, switching the circuit back on, and then testing each wire individually with a multimeter (sometimes the nc tester gives false positives) before doing any work? And if I do find a wire incorrectly colored, is there a good way to label it as such?
Also, what would have happened if the switch I talked about above hadn't tripped the GFCI? When I turned the circuit back on, would the breaker immediately switch it off, or would there be a fire hazard?