Example of 'Exception Continuing Up The Stack'? [Answered]

Quote from book "Only Handle What You Can Fix: If an exception handler cannot resolve the problem represented by the exception, the handler should not exist. Instead, the exception should be allowed to continue up the call stack, hoping that something farther up has meaningful resolution steps for the problem. This is a counterpoint to the previous item. If there is no recourse for an error, it is reasonable for the program to end. There are some allowances here. Sometimes, a handler will repair or address what it can (even just logging the problem) while still allowing the exception to continue (described later)." I'm having a hard time conceptualizing when to use try catch because things break all over the place lol and how 'continuing up the stack' can resolve the issue.
17 Replies
toddlahakbar
toddlahakbar2y ago
Not sure I agree with the author because exceptions should be used for situations that the dev can't handle
BigggMoustache
I thought they meant like, at runtime? or in debug or something?
toddlahakbar
toddlahakbar2y ago
If the dev can't know how to handle an exception, how is the code running supposed to?
BigggMoustache
maybe I should copy more text to clarify
toddlahakbar
toddlahakbar2y ago
Oh, they include logging in the set of things that can resolve the problem
BigggMoustache
what does it mean 'continuing up the stack' and how could that help?
toddlahakbar
toddlahakbar2y ago
I mean, a thrown exception , of not handled, bubbles up the call stack
BigggMoustache
right but i don't understand how that'd resolve it
toddlahakbar
toddlahakbar2y ago
I don't either, is like the assumption is there's more information related to solving the problem in a method father up the call stack
BigggMoustache
like if there were try in calling method and an exception for the type thrown in called method?
toddlahakbar
toddlahakbar2y ago
Sure. So exception in called, not handled in called, caller has a try catch and catches the exception ... how to resolve an exception is so specific to that exception that ... yeah that's an odd statement
BigggMoustache
yeah man I can't make heads or tails of it. I try not to bug the author but I guess I'll just ask them lol
333fred
333fred2y ago
Resolve is a strong word And probably not the right one
toddlahakbar
toddlahakbar2y ago
That's my sticking point. Exceptions should be for things you can't handle
BigggMoustache
okay that's helpful lol yeah it really confused the poop outta me
Mayor McCheese
Logging doesn't resolve the problem (opinion)
Accord
Accord2y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server
More Posts
Cannot find governing FrameworkElement or FrameworkContentElement for target elementI'm trying to make something similar to the `UIElement`'s `InputBindings`, but for some reason, I'm When to use services [Answered]This might sounds like a weird question, is it worth using services in a small-ish non-server consolException vs LogicHello, im going to read a file with File.Readlines(). I read that its better to use logic(like a iMAUI - Weird footer and header when changing from NavigationPage to AppShellI want some kind of "Splash screen" that appears for 3 seconds and then redirect to MainPage (which Mapping outgoing enums to a specific shape in Asp.net Core [Answered]Hello! I'm trying to find a way to take **any **outgoing enums in DTOs from an ASP.NET Core API, anget minecraft versions list [Answered]hello! i wanted to make local minecraft server bootstrap, and i need to get versions list, to make uHow to use RedirectToAction(), RedirectToRoute() or Redirect() to specific endpoints on this Action?I'm unsure on how to correct format the redirect as if only specify the action name it will always dValidating an object not received during a request(FluentValidation) [Answered]Hi, I'm trying to achieve this: I receive Id and someRequest model from an endpoint(separate ID becaDependencies of dinamically loaded .dll are not found [Answered]Hi everyone, I've an ASP.NET Core 6 web app where I have a main project "A" that, if certain conditiIs there a way to make int [] and byte [] point to the same memory area? [Answered]1