I don't think that's Confucius. Doesn't sound like him, can't find any source mentioned online. It appears in a lot of places online, like fake quotes do, but never with a source.
Kudos for this accurate and relevant Confucius quote, it is rare nowadays.
In fact, reading this guy's Analects, you'd find a mine of secular wisdom aphorism that sound obvious but are all the more urgent to remember by the times running.
I don't think the Confucius quote is real, but there are a few relevant ones:
"Not being angry at someone who doesn't know, isn't this a Gentleman?" ??????,??????
"Ji Wenzi thought three times before acting. Confucius heard this, and said 'twice is enough'." ?????????????:“?,????”
In the specific context of his student Zi Zhang asking Confucius about how to get an official salary, he responded: "Hear much and put aside the points of which you stand in doubt, while you speak cautiously at the same time of the others:—then you will afford few occasions for blame. See much and put aside the things which seem perilous, while you are cautious at the same time in carrying the others into practice:—then you will have few occasions for repentance. When one gives few occasions for blame in his words, and few occasions for repentance in his conduct, he is in the way to get emolument." (tr. Legge)
reply