Skip to content

Added error-handling for piping#14

Open
williFiebranz wants to merge 1 commit intosmbache:masterfrom
williFiebranz:master
Open

Added error-handling for piping#14
williFiebranz wants to merge 1 commit intosmbache:masterfrom
williFiebranz:master

Conversation

@williFiebranz
Copy link
Copy Markdown

Changed default behavior of error handling in two ways:

  1. fail_with default is now try(stop(e))
  2. if class(.value) == ‚try-error‘ return .value immediately

Changed default behavior of error handling in two ways:
1. fail_with default is now try(stop(e))
2. if class(.value) == ‚try-error‘ return .value immediately
@smbache
Copy link
Copy Markdown
Owner

smbache commented Jun 12, 2015

Problem is that ensure would no longer "ensure" by default:

get_important_message %>% # suppose this fails, maybe the result is say, `FALSE`
  ensure_that(is.character) %>% 
  send_message

Since try-errors actually pass is.character you could end up sending the error in this example.
Even though this is a pseudo-example it shows that ensure did not ensure that get_important_message got a character message before allowing control to be handed over to send_message, which may send an error rather than the message.

@smbache
Copy link
Copy Markdown
Owner

smbache commented Jun 12, 2015

Also, in your example, why not just have both conditions in one call to ensure rather than chaining them. The latter option is really meant to be used when you don't want to check this before knowing that the previous call passed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants