Hacker News new | past | comments | ask | show | jobs | submit login

Not an expert, but could someone explain why it says: "Panic/recover is not an error handling strategy. A program must panic only when something irrecoverable happens such as a nil dereference." Why is that any more irrecoverable than anything else? (You can check if it's nil before referencing it, right?)



nil when you’re not expecting it.

panic when there is a bug in your program; ie program not behaving as expected, all bets off.

return err when expected conditions fail: bad data, service down, whatever — handle gracefully.


This would be preventing, not recovery.




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

Search: