How do you get punished when you fail a task at work?
Well, if you are a professional athlete, if you lose a game they sack you and never let you play the sport again. However, I see from your profile that you are a programmer so I know if there is a bug in your code they just shoot you dead because no software ever has been released with a bug, right?
Failure happens.
An efficient organisation doesn’t punish people for failingWhat you should do is fall back on the basic rules of D&D (PHB p.6), only for not tryingspecifically, "The DM narrates the results of the adventurers' actions". Or betrayalThese results need not be immediate, or consequential or even (immediately) known to the players. The players have changed the world by their failure (or success) so: what happens?
That is not to say there shouldn’t be consequences, but punishment is not necessarily(necessarily) one of these. Even in modern organisationsAn efficient organisation doesn’t punish people for failing, only for not trying. Or betrayal. Or consistently failing. Or to make an example, Or if they feel like it.
By the way, who is deserving of and who receives punishment are not (necessarily) the same people. Punishment typically flows from politics rather than failure itself.