6 ms·
> So you're not supposed to tell people where errors occur in Scala? You're supposed to use the types `Option` and `Either` or if you're into scalaz then \/ (h
by idobai 10y ago
> So you're not supposed to tell people where errors occur in Scala?
You're supposed to use the types `Option` and `Either` or if you're into scalaz then \/ (http://eed3si9n.com/learning-scalaz/Either.html http://eed3si9n.com/learning-scalaz/Either.html) and Validation (http://eed3si9n.com/learning-scalaz/Validation.html http://eed3si9n.com/learning-scalaz/Validation.html). Throwing exceptions is a childish way to handle errors in FP.
- gozur88 10y agoI don't see why anyone would find this superior to a stack trace.
- idobai 10y agoBecause you need to handle errors properly and not let them sneak into production - there is only a few amount of languages which uses exceptions for eh and they're really suffering from it(ex. Java). Throwing exceptions are a lazy and expensive way for eh. It's far better to write code which notifies the user about the possible output in your API - Option is for when you can't always provide a result and Either is for when various errors could happen. It's really a lame architecture when you need to find exceptions in the logs and talk about it for the modules' developers because some of the exceptions "are OK" - genuine java ee strategy.