12 “Forty years long was I very near unto this generation, and said, It is a people that do always err in their hearts; for they have not known My ways”. The forty years have the same meaning as the word “always.” For that number forty indicates the fullness of ages, as if the ages were perfected in this number. Hence our Lord fasted forty days, forty days He was tempted in the desert, and forty days He was with His disciples after His resurrection. On the first forty days He showed us temptation, on the latter forty days consolation: since beyond doubt when we are tempted we are consoled. For His body, that is, the Church, must needs suffer temptations in this world: but that Comforter, who said, “Lo, I am with you always, even unto the end of the world,” is not wanting. For this was I with them forty years, to show such a race of men, which always provokes Me, even unto the end of the world: because by those forty years He meant to signify the whole of this world's duration.
13....We began with exulting joy: but this Psalm has ended with great fear: “Unto whom I swore in My wrath, that they should not enter into My rest”. It is a great thing for God to speak: how much greater for Him to swear? You should fear a man when he swears, lest he do somewhat on account of his oath against his will: how much more should you fear God, when He swears, seeing He can swear nought rashly? He chose the act of swearing for a confirmation. And by whom does God swear? By Himself: for He has no greater by whom to swear. By Himself He confirms His promises: by Himself He confirms His threats. Let no man say in his heart, His promise is true; His threat is false: as His promise is true, so is His threat sure. You ought to be equally assured of rest, of happiness, of eternity, of immortality, if you have executed His commandments; as of destruction, of the burning of eternal fire, of damnation with the devil, if you have despised His commandments....
Source: The Enarrations, or Expositions, on the Psalms (New Advent)