Trait

com.eharmony.aloha.semantics

ErrorEnrichingSemantics

Related Doc: package semantics

Permalink

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
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def accessorFunctionNames: Seq[String]

    Permalink

    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.

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

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

    Permalink

    returns

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

    Definition Classes
    Semantics

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

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

    Permalink

    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.

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. def provideSemanticsUdfException: Boolean

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Semantics[A]

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped