Your OS will recover itself automatically in such cases and informs you with any critical errors that happened, so you don't have to worry much.
You might consider buying an Uninterruptible Power Supply (UPS), it helps a lot with protecting your computer with power problems.