Skip to content
This repository has been archived by the owner on Jan 25, 2018. It is now read-only.

Optional evaluations and better errors. Closes broadinstitute/cromwell#1830 #67

Closed
wants to merge 5 commits into from

Conversation

cjllanwarne
Copy link
Contributor

No description provided.

@@ -11,10 +11,10 @@ import scala.util.{Failure, Try}
trait WdlValue {
val wdlType: WdlType
def invalid(operation: String) = Failure(new WdlExpressionException(s"Cannot perform operation: $operation"))
def emptyValue(value: WdlOptionalValue) = Failure(VariableNotFoundException(value.toString))
def evaluateIfDefined[A <: WdlValue](optionalValue: WdlOptionalValue, operation: WdlValue => Try[A]): Try[A] = optionalValue match {
def emptyValueFailure(operationName: String) = Failure(new UnsupportedOperationException(s"Sorry! Operation $operationName is not supported on empty optional values. You might resolve this using select_first(optional, default) to guarantee that you have a filled value."))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinging @katevoss for critique!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filled? like a doughnut?

@@ -11,10 +11,10 @@ import scala.util.{Failure, Try}
trait WdlValue {
val wdlType: WdlType
def invalid(operation: String) = Failure(new WdlExpressionException(s"Cannot perform operation: $operation"))
def emptyValue(value: WdlOptionalValue) = Failure(VariableNotFoundException(value.toString))
def evaluateIfDefined[A <: WdlValue](optionalValue: WdlOptionalValue, operation: WdlValue => Try[A]): Try[A] = optionalValue match {
def emptyValueFailure(operationName: String) = Failure(new UnsupportedOperationException(s"Sorry! Operation $operationName is not supported on empty optional values. You might resolve this using select_first(optional, default) to guarantee that you have a filled value."))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should be select_first([optional, default])

@@ -11,10 +11,10 @@ import scala.util.{Failure, Try}
trait WdlValue {
val wdlType: WdlType
def invalid(operation: String) = Failure(new WdlExpressionException(s"Cannot perform operation: $operation"))
def emptyValue(value: WdlOptionalValue) = Failure(VariableNotFoundException(value.toString))
def evaluateIfDefined[A <: WdlValue](optionalValue: WdlOptionalValue, operation: WdlValue => Try[A]): Try[A] = optionalValue match {
def emptyValueFailure(operationName: String) = Failure(new UnsupportedOperationException(s"Sorry! Operation $operationName is not supported on empty optional values. You might resolve this using select_first(optional, default) to guarantee that you have a filled value."))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filled? like a doughnut?

@mcovarr
Copy link
Contributor

mcovarr commented Jan 17, 2017

👍 monads are like burritos, options are like doughnuts.

Approved with PullApprove

@cjllanwarne
Copy link
Contributor Author

@katevoss that + is from a test case which tries something invalid with +. Whatever operationName is gets filled in into the error message as appropriate.

@ruchim ruchim self-assigned this Jan 19, 2017
@Horneth
Copy link
Contributor

Horneth commented Jan 19, 2017

👍

Approved with PullApprove

@cjllanwarne
Copy link
Contributor Author

Will return later!

@cjllanwarne cjllanwarne deleted the cjl_optional_evaluation branch July 11, 2017 11:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants