Timeline for When are try/exceptions not an anti-pattern?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 29, 2023 at 11:20 | comment | added | amon | This answer is a bit inaccurate. Status codes appeared in the 1992 HTTP draft. Try-catch style exception handling was developed in the 70s in the Lisp community. Exceptions went mainstream later. C++ designed exceptions between 1986 and 1990, though implementation/uptake was lagging, and they were later popularized with Java. Berners-Lee was well aware of OOP (first browser was coded in Objective-C), but exceptions weren't yet part of that. However, you're entirely correct that status codes are not errors as far as the HTTP protocol is concerned. | |
Apr 28, 2023 at 20:38 | comment | added | Daniel | ahh OK, I see what you are saying. Thank you very much for explaining! | |
Apr 28, 2023 at 20:15 | comment | added | Martin Maat | @Daniel You got your response and all is well, you can switch your way out of there. Throwing after you get a perfectly valid response, handling the exception and then returning a result value after all defeats the purpose of using exceptions. | |
Apr 28, 2023 at 19:33 | comment | added | Daniel | hm...could I trouble you to help me better understand your point? if I expect that this call to fetch will succeed (i.e., return a 200), and it doesn't succeed, how is that not something that went wrong in my program? What if I claim that any response other than 200 IS something that went wrong? (i.e., not the way my program was expected to run?) is my point of view incorrect? I see what you are saying that there are many possible responses, but would you agree that some responses are desirable and others not (ie., success and exception)? | |
Apr 28, 2023 at 19:24 | comment | added | Martin Maat | @Daniel I was explicit about this. They are not "errors in the sense that something went wrong in your program". HTTP may call it an error, to your client application they are just some of many possible and expected responses. | |
Apr 28, 2023 at 19:18 | comment | added | Daniel | 4xx and 5xx status codes are called "errors" (client errors and server errors) developer.mozilla.org/en-US/docs/Web/HTTP/Status. How should one harmonize what your answer says with how that link (among many other resources) characterizes those status codes? | |
Apr 28, 2023 at 19:09 | history | answered | Martin Maat | CC BY-SA 4.0 |