There are a couple of things that you can try.
If your code is getting triggered often, and multiple times in rapid succession, then you should implement LockService.
Then there is the issue of services being used too often in a short period of time, and hitting the quota limit.
For that situation, you need to use a "backoff" technique in your code, where you try and then catch an error, wait and try again.
var L = 4;//Try up to 3 times
for (var i=1;i<L;i++) {
try{
//Your code here
break;//If successful then the loop will break
}catch(e){
if (i!==L-1){Utilities.sleep(i*1500);}
if (i>=L-1) {
Logger.log('error: ' + e.error)
//console.error('ERROR - : ' + e + ' Stack: ' + e.stack + "\n\n" + r);
}
};
}