Hacker News new | ask | show | jobs
by layer8 398 days ago
When you receive an HTTP response, it can contain a status value outside the valid range as well. So you have to handle those one way or the other.

Regarding the int type, a better solution would be to provide the ability to define a restricted integer type, so that the compiler can help.

1 comments

Okay? So you cast it to the enum and instantly know it’s not a case you support.

It’s built in validation.