Skip to content
This repository was archived by the owner on Mar 29, 2019. It is now read-only.

Conversation

@devxoul
Copy link
Owner

@devxoul devxoul commented Oct 26, 2016

This is for whom wants handle each errors.

From the comment from Reddit:

Keeps it short and sweet. My biggest concern is that it's limiting errors to control flow. If get("A") and get("B") fail and we get("C") instead, what happened to the errors from the previous 2 calls? It looks to me like it only throws the last error.

Examples

let value: String = fallback {
  return try get("a")
}.catch { error in // error from "a"
  return try get("b")
}.catch { error in // error from "b"
  return try get("c")
}.finally { error in // error from "c"
  return "none"
}
print(value) // "none"
let value: String = try fallback {
  return try get("a")
}.catch { error in // error from "a"
  return try get("b")
}.catch { error in // error from "b"
  return try get("c")
}.rethrow() // will throw error from "c"

To Do

  • Implement
  • Test
  • Documentation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants