Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 3
    "People are scared of exceptions for some reason" - sure, because in most (not all) languages a raised exception has a significant performance impact. Next reason is that an exception changes the program flow in an sometimes unexpected way. Exceptions have their place and are a good tool, if you do it right. Commented Jul 21, 2014 at 7:15
  • 3
    The questioneer's code is making HTTP requests. I don't think an exception is going to make an appreciable difference to the performance. I agree that you can't stop clients from handling exceptions badly, but you also can't stop them from ignoring return codes (which I'd argue is an easier mistake to make) Commented Jul 21, 2014 at 9:52
  • 1
    Sure. And how is the "old school of thought" related to HTTP requests? Just asking. Commented Jul 21, 2014 at 15:18
  • 3
    "which I'd argue is an easier mistake to make": This depends on the language you are using. If your language supports algebraic data types, then the error code is just an extra option in your return data type and the compiler will complain if you do not handle it in your code. Commented Jul 21, 2014 at 17:26
  • Yeah, I am now convinced that ADTs are exactly what I need. In C#, however, I suppose it really comes down to a choice between a return code and an exception. Solution I described in OP is basically about return codes. I'd say it's more likely that client will notice that there are two classes inheriting from ChangePasswordResult and start thinking about what it means - to notice the method can throw an exception, he would have to open up docs and really, what is a chance of that happening? Declared exceptions would help here, but this is another thing C# lacks.... Commented Jul 21, 2014 at 21:17