Replies: 1 comment 4 replies
-
What are you suggesting? Throwing exception everywhere instead? I get that sometimes throwing a specific exception that could have some logging attached to it. Maybe we won't know if it didn't work because either the file was moved or the folder didn't have permissions or whatever. It might be useful is SOME location to give feedback, but that seems like a hell of work to refactor this whole program and go through each and every exception to figure out what might go wrong at every possibility. But at the end is it really useful for the end user? An exception was handled, it was excepted my the developer. So unless it crashes the program or does something weird the won't care really. If it does lead to a crash there is a system to catch unhandled exceptions and show the stack trace to the user. Checking for null is completely normal it isn't just because of an exception. In your example, the Deserialize might have also returned a null or DisableNtfs was true and DisableSidecar was also true, then comicInfo may be null, then you want to make sure that you don't return the null value. You want to actually make sure to load from the xml embedded in the actual CBZ at the end. Also with newer framework with nullable turned on, the compiler will actually tell you this might be a null and you WILL need to do a check. I think both approach have some merit, but just throwing exception everywhere and catching them all isn't really a solution. In that example we would have needed to add a try..catch at the second location also. Doing try..catch does have an effect on performance beside just null checking. |
Beta Was this translation helpful? Give feedback.
-
Having started to browse the code, I see several instances where exceptions are caught and null is returned, discarding all context.
In turn, null returns are checked at fn invocation.
This is almost like C-style return codes, and while it works it discards useful information.
Debugging (and error reproduction) could be improved with some logging in place.
We could follow this up by evaluating what exception should be propagated with potential user prompts.
An example for discarded exception:
...and null check:
Beta Was this translation helpful? Give feedback.
All reactions