I wish I had some advice that will help but I have been in a bad place for almost four years now due to a startup not going well after a decade of work. I wasn't a founder and yet my entire sense of self worth was tied to what I was doing.
Now? I cannot even get past the first round of interviews at the vast majority of companies I interview at. I would like to say that it isn't because I cannot code, but at this point my sense of self worth in terms of programming is rock bottom. I make mistakes - sure all people do - but when coding and making mistakes or not catching bugs each instance is added to an enormous pile of ever growing pain that I place on myself: obviously this is why companies don't want me. Obviously this is why I have been making $60k on average for my entire career. Because I am not worth anything. Yes I know that making something is more than making nothing. Yet the way people throw around salary numbers on this site just makes me want to turn away from everything in despair.
To make matters worse I now work at a place that tasked me with leading a team to make fundamental changes to our product which the business is counting on to expand its sales. The employees' spoken language itself is not my native language. The entire system was rewritten with new tech - some of which I had no prior experience using. Oddly I didn't seem to have control over the technical decisions being made by the engineers on my team. When I voiced concerns or laid out criticism, someone complained (a junior with 3 months of bootcamp prior to his joining the company) and the director of engineering told me I was needed to stop harassing the team. One of those "if someone is liked it doesn't matter what they actually do" scenarios. Things didn't go well. We overshot our, I would say, ridiculously optimistic development timeline, which was originally set by the director to please the higher ups, by 50% (1 year 4 months -> 2 years 4 months). The directory threw me under the bus from my point of view.
Now I am trying to find a new workplace. This entire time I continuously ask myself if perhaps I am the problem and it destroys me.
I don't know what to say but I hope you are not mentally where I am. Hopefully you find a way out. As someone older than you I guess I can say: you have more time than I do at least.