handle exceptions thrown by captcha provider

This commit is contained in:
hrj 2022-04-02 22:51:19 +05:30
parent 4f3bec0bc6
commit d7c1f9a4cc

View File

@ -34,6 +34,7 @@ class CaptchaManager(config: Config, captchaProviders: CaptchaProviders) {
} }
def generateChallenge(param: Parameters): Option[Int] = { def generateChallenge(param: Parameters): Option[Int] = {
try {
captchaProviders.getProvider(param).flatMap { provider => captchaProviders.getProvider(param).flatMap { provider =>
val providerId = provider.getId() val providerId = provider.getId()
val challenge = provider.returnChallenge(param.level, param.size) val challenge = provider.returnChallenge(param.level, param.size)
@ -42,6 +43,11 @@ class CaptchaManager(config: Config, captchaProviders: CaptchaProviders) {
// println("Added new challenge: " + token.toString) // println("Added new challenge: " + token.toString)
token.map(_.toInt) token.map(_.toInt)
} }
} catch {
case e: Exception =>
e.printStackTrace()
None
}
} }
private def insertCaptcha( private def insertCaptcha(