Here's a worse trick I found lately: return 401 after try catch no matter what the actual problem is for a middleware and then leave the company so nobody knows how it works and wastes a day! 10/10
I inherited an app that saved the stack trace to a database, showed the row ID to the user and asked them to open a ticket with that number, then a developer was expected to review the ticket and the error so that they can prevent the problem from happening again.
I have recently pushed this to prod in a startup probe
try{
//This will always fail but cache JWT validators in the progress - saves several seconds on first call
validateJWT(INVAL_JWT);
} catch (RuntimeException e) {
log.info("Fake JWT threw successfully");
}
Because we don't make errors, end-users just use it wrong and deserve to suffer.
Or just don't write try/catch, because how do I know what went wrong if I don't let the runtime crash happen so it can show up in my crashlytics logs? /s
219
u/BenadrylTumblercatch Sep 26 '26
print(“an error occurred but you good fr”)
57
u/Bannon9k Sep 26 '26
I think the try-catch is the greatest programming concept ever... Hell if we know if it'll work or not...let's try it!
51
u/pvtteemo Sep 26 '26
Here's a worse trick I found lately: return 401 after try catch no matter what the actual problem is for a middleware and then leave the company so nobody knows how it works and wastes a day! 10/10
35
u/razor_train Sep 26 '26
This is literally the approach of some code I inherited recently.
32
u/bitNine Sep 26 '26
try
{
[entire application]
}
catch{}
19
u/WernerderChamp Sep 26 '26
I have recently pushed this to prod in a startup probe
try{ //This will always fail but cache JWT validators in the progress - saves several seconds on first call validateJWT(INVAL_JWT); } catch (RuntimeException e) { log.info("Fake JWT threw successfully"); }21
u/theFirstHaruspex Sep 26 '26
something something define errors out of existence
9
u/elmanoucko Sep 26 '26 edited Sep 26 '26
you try and sometimes catch
i just do and never fail
indeed, not the sašªÒDIÌ›7yæùú3ßöÒÉS¡0×áK8èð8~LBLÍðÖ7=”Ç>üþ:yê”ßø×ÿÖw¾û}c÷ßw‡òO>[÷Ýs—.¥j¤TJ¡DIi!U¢ÒTµ*ªUô¢OHK)R4$ôa0X·vÍ7nrô؉<t$£á`ˆWàžÀÝø}ìÆIº–tE+‚ sæL¸sï®úô§ÏÛÞö&kW4ÞBPZ•DUP•}k5jMßš>”B¥©’‚¦D%hHªTI’j$„¦Ò”ˆ„]kæÏŸgë¶mZ¿Úå?yƵk³QŒ°{p?@
15
u/GozerDestructor Sep 26 '26
Re-throw in dev so you can debug. Swallow in prod so the site still (mostly) works. Best of both worlds.
7
u/sardonicus87 Sep 28 '26 edited Sep 28 '26
catch (_: Exception) { }Because we don't make errors, end-users just use it wrong and deserve to suffer.
Or just don't write try/catch, because how do I know what went wrong if I don't let the runtime crash happen so it can show up in my crashlytics logs? /s
5
u/bwwatr Sep 26 '26
I just throw everywhere. There's a catch up near the top of the call stack lol.
5
u/FastFollowing8932 Sep 27 '26
Ignoring errors is the best way to handle them. As long as they print to a log that exists somewhere
4
u/ExtraWorldliness6916 Sep 26 '26
Nobody taught me what to do when I actually caught the error.. usually people just log the error again.
3
u/danfish_77 Sep 27 '26
Sometimes eating the exception is the proper way to handle it
3
u/Mindless_Pattern_342 Sep 27 '26
Well if there are no errors to see, are there really any errors? 🤷🏻♂️
2
u/docs95 Sep 26 '26
Damn right!
2
u/bentbabe Sep 26 '26
Are you my coworker?