News for hackers. Stuff that matters.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by sonicgear1 on Thursday July 13, 2023 @07:11PM (#36717346)
You should catch any non specific exception in the last catch block, just in case. Thought that was the standard. Java gets very messy in mixing checked and unchecked exceptions, I've seen a lot of devs just ignore the unchecked ones.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by int_19h on Thursday July 13, 2023 @10:28PM (#36718750)
And do what with it? If you don't know what it really is, the best thing is to let things fail fast and the standard logging to kick in and record all the details of the crash.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by yardstick on Thursday July 13, 2023 @10:36PM (#36718794)
Depends on what you are doing.

If I’m processing a monthly report for millions of customers, I don’t want to abort processing after running into one problem customer. I want to continue to process the rest of them, and log the problem customers exception for troubleshooting and analysis offline.

Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by nradov on Friday July 14, 2023 @07:52PM (#36731573)
Depending on what actually happened, that could be disastrous and result in data corruption or account reconciliation failures or worse. It often would be safer to go ahead and fail even in that circumstance.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by breadwinner on Thursday July 13, 2023 @10:32PM (#36718770)
So you mean, catch the root Exception class. Pretty much everyone agrees that's a bad idea, C# and Java both advice against that. But in the case of C# you have to do it, to avoid crashing all the time, because there's no reliable way to determine what exceptions can be expected. In Java the compiler will tell you what exceptions can be expected, but in C# you have to rely on documentation which is not reliable.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by yardstick on Thursday July 13, 2023 @10:41PM (#36718823)
Not just Exception. Throwable.

I’ve seen too much code were some random problem in an Error - OutOfMemoryError for example when processing too much data (Eg call data records, payment records, analytic records, whatever). If it’s a batch processing job, you don’t want this problem for this specific entity causing the rest of your reports not to be sent.

I’ve also seen stupid things like RPC libraries silently swallow Errors and not report them properly to the caller, so we end up wrapping all RPC server endpoint methods in a try-catch-Throwable just so we can see the problem and log it.

Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by kaba0 on Friday July 14, 2023 @09:38AM (#36723847)
You can’t necessarily recover from errors.