42 ms·
I tried implementing this logic in java with a try-catch style: try { Validation validation = validate(); try {
by AndrewPGameDev 3y ago
I tried implementing this logic in java with a try-catch style:
try {
Validation validation = validate();
try {
Value value = update_db(validation);
send_email(value);
} catch (DBError db) {
try {
sleep(5);
Value value = update_db(validation);
send_email(value);
} catch(InterruptedException ie) {
// do nothing, stupid java-ism
} catch(DBError db2) {
try {
Value value = update_db_remote(validation);
send_email(value);
} catch (DBError db3) {
notify_user(db3);
} catch (EmailFailedError e) {
requeue_email(e);
}
} catch (EmailFailedError e) {
requeue_email(e);
}
} catch (EmailFailedError e) {
requeue_email(e);
}
} catch(ValidationError v) {
notify_user(v);
}
https://gist.github.com/Andrewp2/9d97bd213b061166d6df565ce26dc838 https://gist.github.com/Andrewp2/9d97bd213b061166d6df565ce26...
IMHO this is much worse than the railway version you gave, but maybe someone could write a superior version that still uses try-catch.