com.eharmony.aloha.semantics

ErrorEnrichingSemantics

trait ErrorEnrichingSemantics[A] extends Semantics[A]

User-defined functions used in feature specifications can cause models to throw undesirable exceptions. This semantics mixin can allow the the exception to be caught, reformulated as a com.eharmony.aloha.semantics.SemanticsUdfException and rethrown. This has the distinct advantage of providing the caller with the exact feature specification that failed along with the features that were present and missing and the input data that caused the problem.

Example usage: Assume a we have an implementation UnsafeSemantics, implementing com.eharmony.aloha.semantics.Semantics\[Xyz\]. We can recast the errors by doing

// An object (note that because provideSemanticsUdfException = true by default, we don't need to specify it if
// we want this semantics to always enrich exceptions.
object SemanticsObjWithEnrichedErrors
    extends UnsafeSemantics
    with RethrowingSemantics[Xyz]

// Here's a way to create a class to allow the caller to specify whether he wants
// [[com.eharmony.aloha.semantics.SemanticsUdfException]]s to be provided.
case class SemanticsClsWithEnrichedErrors(override val provideSemanticsUdfException: Boolean = true)
    extends UnsafeSemantics
    with RethrowingSemantics[Xyz]
val featureSpecification = "[Some feature spec here ...]"
val xyz: Xyz = getXyz()
// Don't just call right.get in prod.
val f = SemanticsObjWithEnrichedErrors.createFunction[SomeOutputType](featureSpecification).right.get

// If the following line throws an exception, it'll throw a SemanticsUdfException which provides additional
// information.
val r = f(xyz)
A

the input type.

Linear Supertypes
Semantics[A], Closeable, AutoCloseable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ErrorEnrichingSemantics
  2. Semantics
  3. Closeable
  4. AutoCloseable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def accessorFunctionNames: Seq[String]

    Returns the string representations of all of the data "variables" used by functions created from this Semantics object.

    Returns the string representations of all of the data "variables" used by functions created from this Semantics object.

    returns

    Definition Classes
    Semantics
  2. abstract def close(): Unit

    Definition Classes
    Closeable → AutoCloseable
    Annotations
    @throws( classOf[java.io.IOException] )
  3. abstract def refInfoA: RefInfo[A]

    returns

    a com.eharmony.aloha.reflect.RefInfo for input type A.

    Definition Classes
    Semantics

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def createFunction[B](codeSpec: String, default: Option[B] = None)(implicit arg0: RefInfo[B]): Either[Seq[String], GenAggFunc[A, B]]

    Create a function from A to B.

    Create a function from A to B. If provideSemanticsUdfException is false or the generated function is is com.eharmony.aloha.semantics.func.EnrichedErrorGenAggFunc return the function; otherwise, return the function wrapped in an com.eharmony.aloha.semantics.func.EnrichedErrorGenAggFunc. com.eharmony.aloha.semantics.func.GenAggFunc produced by the underlying semantics.

    B

    The return type of the function.

    codeSpec

    specification for a function to be produced by this semantics.

    default

    a default value in the case that the function would produce an optional type.

    returns

    Definition Classes
    ErrorEnrichingSemanticsSemantics
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. def provideSemanticsUdfException: Boolean

    Only when this function returns true will the functions produced by this semantics be wrapped in a com.eharmony.aloha.semantics.func.EnrichedErrorGenAggFunc.

    Only when this function returns true will the functions produced by this semantics be wrapped in a com.eharmony.aloha.semantics.func.EnrichedErrorGenAggFunc. The default for this function is true. Therefore, when mixing in this trait override this function if we don't want to always wrap the generated functions.

    returns

    Attributes
    protected[this]
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  20. def toString(): String

    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Semantics[A]

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped