Self-serving bias
A self-serving bias is one where we attribute our failures to external factors and our successes to our own admirable qualities and efforts.
So, a tennis player might internally credit their athleticism and skill for their victory, while the loser may blame the umpire's decisions, their racket or the court. You might have seen it in professional sports.
Self-serving bias may be rational and positive, maintaining our self-esteem and a positive view of ourselves. Conversely, it can hide reality (and give referees and umpires a more draining job) or cause us to reject negative but objective feedback.
Self-serving bias is a form of attribution bias where we misattribute behaviours or events to characteristics rather than circumstances or vice versa.
Self-serving bias is covered nicely (pdf) by Donelson R. Forsyth in the International Encyclopedia of the Social Sciences, 2nd Edition.