lift / lift/framework

Or-ing two Failures should somehow combine them

Open
#1,184 2 comments 0 reactions 1 assignee View on GitHub

@dpp is already working on this.

Since Mar 1, 2012.

Common P:Normal T:Enhancement
Dominant language
Scala
Stars
1.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Two failures that are or-ed should return a failure that somehow combines both causes.

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]?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.