Or-ing two Failures should somehow combine them
Two failures that are or-ed should return a failure that somehow combines both causes.
Example:
Currently:
Desired behaviour:
Something that can give all 3 messages/exceptions if all of them failed because current behaviour swallows exceptions and return only the last one, that might be not the one that the user is interested in.
Or-ing Failure and Empty can return the one Failure or maybe some combined Failure that has both?
Just chaining might be not enough, because it's not clear how or() result can chain two Failures that have chains themselves. Maybe it would be useful to have MultiFailure class extending Failure just as there is ParamFailure? Or maybe Failure.chain should be List[Failure] not Box[Failure]?
Example:
$ def getFromProperties = Failure("Property not set")
$ def getFromFilesystem = Failure("File doesn't exist")
$ def getFromDb = Failure("DB not configured")
$ def getSomething : Box[Something] = getFromProperties or getFromFilesystem or getFromDb
Currently:
$ getSomething
Failure("DB not configured")
Desired behaviour:
Something that can give all 3 messages/exceptions if all of them failed because current behaviour swallows exceptions and return only the last one, that might be not the one that the user is interested in.
Or-ing Failure and Empty can return the one Failure or maybe some combined Failure that has both?
Just chaining might be not enough, because it's not clear how or() result can chain two Failures that have chains themselves. Maybe it would be useful to have MultiFailure class extending Failure just as there is ParamFailure? Or maybe Failure.chain should be List[Failure] not Box[Failure]?
Leave a comment