I always try to take the view that anyone pointing out my mistakes is just being helpful, and to be grateful for it instead of being offended.
I used to struggle with this like you describe, and still do to some extent, but I think the fundamental cause is just insecurity, at least in my case.
I just have to remind myself that everyone makes mistakes all the time, and that's why we have code review. If someone spots a mistake in my code in review, they just saved me from looking even dumber down the line when something breaks in prod. I've also learned that feedback from others is the single most powerful way of identifying holes in your knowledge.
Over time, by forcing myself to look at things in this framing, I've come to mostly enjoy constructive criticism, and see it as an opportunity rather than be offended.
I used to struggle with this like you describe, and still do to some extent, but I think the fundamental cause is just insecurity, at least in my case.
I just have to remind myself that everyone makes mistakes all the time, and that's why we have code review. If someone spots a mistake in my code in review, they just saved me from looking even dumber down the line when something breaks in prod. I've also learned that feedback from others is the single most powerful way of identifying holes in your knowledge.
Over time, by forcing myself to look at things in this framing, I've come to mostly enjoy constructive criticism, and see it as an opportunity rather than be offended.