How to detect and repair errors in mesh?
The operator is called Select Non Manifold in Mesh menu. It should help you  to find out weird mesh. With further configuration, you can choose what you want to inspect.

After you select those vertices, you still need to clean up them by hand or using operator again:

But don't rely on these method to fully fix your mesh since if your mesh is broken in some degree, that mesh will probably been so weird that algorithm can not figure how to fix it.