News for hackers. Stuff that matters.
Re:You’re better off using Exceptions by _ZeD_ on Monday February 03, 2020 @01:15PM (#22227128)
That is a wonderful idea. You don't need to deal with 404, 500 or other stuff, you just write for the "happy path". The framework deals with the rest.
Re:You’re better off using Exceptions by mumblemumble on Monday February 03, 2020 @01:43PM (#22227441)
It's both wonderful and terrible.

On the one hand, it's terribly convenient when you're writing the code.

On the other hand, as clon says, it breaks encapsulation. Not necessarily, but I've rarely seen these style of Web frameworks used in a way that doesn't result in network communication concerns wormholing their way through the entire codebase. And it sometimes does do weird things with control flow. Again, not necessarily but in practice. For example, JAX-RS frameworks do the exception mapping off in some magic location that's outside the part of the call stack that you directly control, meaning that customizing the logic requires hacking some fairly complex special-purpose mechanisms into the framework.

I suspect that there's a way to achieve convenience without relying on spooky action at a distance. But one could be forgiven for looking at the way popular frameworks on popular platforms work and concluding that cleanliness must be the price of convenience.

Re:You’re better off using Exceptions by majewsky on Monday February 03, 2020 @01:29PM (#22227282)
Then you fill in a complex form with 6 object references, and the framework just spits out "NOT FOUND", which means "have fun figuring out which one is the missing object".
Re:You’re better off using Exceptions by joshuamorton on Monday February 03, 2020 @01:59PM (#22227616)
`raise MissingField(field_name)` solves this problem.
Re:You’re better off using Exceptions by ravenstine on Monday February 03, 2020 @02:01PM (#22227633)
At which point you end up doing the same work you would have had to do in the first place, except with extra lines for exception handling. ;)