Do we need to close the response object if an error occurs while calling http.Get(url)?

General concept is that when a function (or method) has multi return values one being an error, error should be checked first and only proceed if the error is nil. Functions should return zero values for other (non-error) values if there is an error. If the function behaves differently, it should be documented. http.Get() does … Read more

Handling errors in ANTLR4

Since I’ve had a little bit of a struggle with the two existing answers, I’d like to share the solution I ended up with. First of all I created my own version of an ErrorListener like Sam Harwell suggested: public class ThrowingErrorListener extends BaseErrorListener { public static final ThrowingErrorListener INSTANCE = new ThrowingErrorListener(); @Override public … Read more

Why are Exceptions said to be so bad for Input Validation?

Reading these answers, I find it very unhelpful to say, “Exceptions should only be used for exceptional conditions”. This begs the whole question of what is an “exceptional condition”. This is a subjective term, the best definition of which is “any condition that your normal logic flow doesn’t deal with”. In other words, an exceptional … Read more

How to do error handling in Rust and what are the common pitfalls?

Rust generally solves errors in two ways: Unrecoverable errors. Once you panic!, that’s it. Your program or thread aborts because it encounters something it can’t solve and its invariants have been violated. E.g. if you find invalid sequences in what should be a UTF-8 string. Recoverable errors. Also called failures in some documentation. Instead of … Read more

How do I make a “generic error” page in my ASP.NET application so that it handles errors triggered when serving that page itself?

I like to start by categorize the possible errors. Categorize the errors. Page Not Found (this is full my log). Breaking parameters of the page by trying to hack it Error from wrong user data input. Totally Unknown error – a new bug that we must fix. a Very hard General error – nothing runs … Read more

User Input of Integers – Error Handling

There is still a problem in your “solved” code. You should check for fail() before checking the values. (And obviously, there is the problem of eof() and IO failure as opposed to format problems). Idiomatic reading is if (cin >> choice) { // read succeeded } else if (cin.bad()) { // IO error } else … Read more

404 Redirecting for non aspx pages

As dbaseman states this is because the asp.net handlers are not called for non-asp.net files. An easy way to force the asp.net handler to operate on all requests is to set the following in your web.config. <system.webServer> <modules runAllManagedModulesForAllRequests=”true”> </system.webServer> This tells IIS to run through all of the managed modules for all requests such … Read more