• 0 Posts
  • 5 Comments
Joined 8 days ago
cake
Cake day: October 9th, 2026

help-circle
  • That is one option, not the only. The whole point would be “expose this type of error if something downstream is actionable based on the type”. Even if you went with an enum error handling approach you would still run into this dilemma if you want to handle “correctly”. So yes, a better identifying type for this type than ParseIntError would be ideal. You could still choose to go the untyped route and downcast as well. If you own the domain, this certainly is not “wrong”. If the error recovery path for every error is “fallback to a default port”, then you really don’t have to go the newtype route at all. But if there is multiple error recovery paths, then e.g. a PortSetError may be ideal.


    score 1 · canonical