All Downloads are FREE. Search and download functionalities are using the official Maven repository.

yakworks.api.problem.Exceptional.kt Maven / Gradle / Ivy

There is a newer version: 3.14
Show newest version
package yakworks.api.problem

/**
 * An extension of the [Problem] interface for problems that extend [Exception]. Since [Exception]
 * is a concrete type any class can only extend one exception type. [ThrowableProblem] is one choice, but we
 * don't want to force people to extend from this but choose their own super class. For this they can implement this
 * interface and get the same handling as [ThrowableProblem] for free. A common use case would be:
 *
 * 
`public final class OutOfStockException extends BusinessException implements Exceptional
`
* * * @see Exception * * @see Problem * * @see ThrowableProblem * * WIP Not really doen yet */ interface Exceptional : Problem { val cause: Exceptional? fun propagate(): Exception { throw propagateAs(Exception::class.java) } fun propagateAs(type: Class): X { throw type.cast(this) } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy