Ismayil Khayredinov
1 min readSep 20, 2019

--

Now imagine your code was an HTTP request and you had to return a correct status code with your error message. Or suddenly your program needed to be internationalized. You would have a really hard time refactoring your code. I don’t think returning error string is good practice. Throw an error, return a value, IMO. You are explaining an important concept, but I think it’s a bad example.

Edit Nov 24, 2019: I have finally had some time to put together a response explaining my position. You can see it here: https://medium.com/@ismayilkhayredinov/improve-your-controller-logic-with-assertions-and-exceptions-e6efa7009550

--

--

Ismayil Khayredinov
Ismayil Khayredinov

Written by Ismayil Khayredinov

Software engineer who combines optimism with pessimism to build robust and idiot-proof solutions

Responses (3)