Exception safety refers to the guarantees provided by a piece of code when exceptions are thrown, ensuring that resources are not leaked and the program remains in a valid state. It is categorized into different levels, including basic, strong, and no-throw guarantees, each offering varying degrees of safety and complexity.