package play.api.libs.ws.ssl
import java.security.cert.CertificateException
class CompositeCertificateException(msg: String, val throwables: Array[Throwable]) extends CertificateException(msg) {
def getSourceExceptions: Array[Throwable] = throwables
}
object CompositeCertificateException {
def unwrap(e: Throwable)(block: Throwable => Unit) = {
var cause: Throwable = e
while (cause != null) {
cause match {
case composite: CompositeCertificateException =>
composite.getSourceExceptions.foreach { sourceException =>
block(sourceException)
}
case other =>
block(other)
}
cause = cause.getCause
}
}
}