Skip to content

Commit

Permalink
catch only non-fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarter97 committed Feb 28, 2022
1 parent 98fe20b commit 42caac9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/scala/com/sky/kafka/topicloader/config/config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cats.implicits._
import com.typesafe.config.ConfigException

import scala.util.Try
import scala.util.control.NonFatal

package object config {
type ValidationResult[A] = ValidatedNec[ConfigException, A]
Expand All @@ -16,7 +17,8 @@ package object config {
implicit class EitherOps[A](e: Either[Throwable, A]) {
def validate(path: String): ValidationResult[A] = e.leftMap {
case ce: ConfigException => ce
case e: Throwable => new ConfigException.BadValue(path, e.getMessage)
case e if NonFatal(e) => new ConfigException.BadValue(path, e.getMessage)
case e: Throwable => throw e
}.toValidatedNec
}
}

0 comments on commit 42caac9

Please sign in to comment.