function main() {
try {
//Insert your script logic here
} catch(e) {
//Catch any error here. Example below is just sending an email with the error.
MailApp.sendEmail('INSERT_EMAIL_ADDRESS_HERE',
'Sample Script - Error',
e);
}
}