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

Add support chaining - #1

Open
devxoul wants to merge 1 commit into
masterfrom
chaining
Open

Add support chaining#1
devxoul wants to merge 1 commit into
masterfrom
chaining

Conversation

@devxoul

@devxouldevxoul commented Oct 26, 2016

Copy link
Copy Markdown
Owner

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

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

To Do

  • Implement
  • Test
  • Documentation

Sign up for freeto 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.

1 participant

@devxoul