Being labeled mentally ill can feel like it's gas lighting, especially if oneself knows their self to be just as rational and competent as anyone else. Mental illness is often a matter of circumstance. Of course people who are homeless or fear the worst happening to them over and over are going to appear as though their decision making is being degraded by being called mentally ill. It's basically like being called an idiot, which is ironic, because, lots of mental healthcare attempts to reduce stigma, but still must discriminate between types of individuals for diagnosis, even though people really, really can't be labeled that way. It's always an observer bias.
I don't know if this helps or hurts generally, about mental illness, I don't know your specific circumstance or people you have interacted with who have mental illness. But feeling slapped with a label for the rest of your life feels like a huge burden to carry. Just because, you made some big 'mistakes', in front of someone who had the authority to give you that label.
Something I'm personally very stubborn about, and very outspoken about, is mental illness discrimination. You can read through these papers and see if they make sense to you, if you want to. I'm not sure how many of the papers I've read throughout my life about psychology, neuroscience, etc, but I've read a lot. I'm not a psychologist, therapist, or anyone who has been correctly (via an accredited institution) educated in mental health care, and I only study myself, and to a lesser degree, my family, as they study me. Mental illness should be a label you can have removed - because every variation of behavior mental illness describes as negative can also have a positive side, and trying to remove all the things mental illness labels as negative can really be handicapping, eventually. You need 'black and white' thinking for software development. Application of it to social systems, can be useful, but only in chaotic social systems where people identify you as 'the enemy', which is just as much up to them as it is to you.
Trying to identify one big thing as 'the error' in life just, this a burdensome mindset to have. No matter what it gets attached to. Oneself can convince oneself they believe 'that was it, that was the error' at any moment in time. Those things aren't future proof, and it's erroneous to assume they are.
https://www.tandfonline.com/doi/abs/10.1080/1747091080231971...
http://www.jneurosci.org/content/25/49/11489?utm_source=Tren...
https://www.nature.com/articles/s41598-018-29561-w
http://science.sciencemag.org/content/343/6171/675