Well I agree with all above and you must take the matter wisely, should not think about credit and lose your confidence but to do something to win his trust. I know it is not too easy and when seniors treat their juniors badly and not just treat them badly but do more than this, make them really feel bad, they lost their confidence and this impact on their behavior and work style. And Employee started thinking over switching the job and also does mistakes.
“A bend in the road is not the end of the road”, and what I think is that one must fight with this problem because this can teach and train an employee to handle work pressure and the related things such as how to handle the situational and work conditions, how to behave and control on ourselves, gets our decision power stronger time to time, gives us a unbeatable experience which helps us by many ways in future..
“Action speaks louder”, and as other said here that you need to be polite, calm and sober and sincere with your work, I also would suggest you to deal with him in a good manner and don’t let him have a chance to yelling at you. Do your work properly and sincerely without expecting his appreciation or anything. Let him do what he is doing. When he’ll realize his mistake and found you good and confident with your work, you will certainly feel good and get the chance to grow.
“The only thing that overcomes hard luck is hard work”
Moreover, fact is that you are under him and working with him, so he has have to assign you work and for this you have to build a confident relationship with him first.
From all of above, I can understand your situation better bcz I also have gone through the similar situation in my past and have conquered in a good manner..
That was all from my experience I was sharing here and hope will work for you.. Best of Luck