There are engineering practices that help to make sure errors will be caught early, and that applies to all engineering fields.
With software you must distinguish between design documents made before you start coding and documentation you make afterward to *explain*.
But there are also tools that help prove that your specification or your design is correct. You have to write them formally and the tool checks for consistency and safety. This is used in safety critical designs. Of course the device can be perfectly safe but not doing what was required, that's another subject.
There is an analogy with the coding phase. If the language has features that prevent bugs your code won't make harm but this does not ensure it will be consistent with the design.
Unless you have a CASE tools that checks the correctness of the specification and writes the code automaticaly you have to use *good engineering practices* to avoid mistakes as far as possible. Such tools exist but they are limited to specific applications such as control. AFAIK, there is no universal tool for all kinds of software.