Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am a bit surprised exceptions were not mentioned in the context of returning an error value.


The idea was to show things that actually make sense as return values / statuses rather than exceptions. I surely wouldn't throw an exception for "getline reached EOF"


Yeah, I am not for overusing exceptions, but languages like python make creative use of exceptions. For instance the generator syntax raises an exception when it is done. Interestingly, you can make a generator to go through the lines in a file, and use that when you are at the EOF.


It is certainly a good way to _avoid_ throwing exceptions in a public API.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: