Attempt to find exception?????
authorTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 6 Feb 2022 23:10:56 +0000 (18:10 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 6 Feb 2022 23:10:56 +0000 (18:10 -0500)
src/jvmMain/kotlin/starshipfights/auth/providers.kt
src/jvmMain/kotlin/starshipfights/data/data_documents.kt

index ac24f2c0d980195ea274dfb73245d447c05f98ca..abd3eb7aff285e376fca25b461ab48eca94f75cb 100644 (file)
@@ -14,6 +14,7 @@ import io.ktor.util.*
 import kotlinx.coroutines.coroutineScope
 import kotlinx.coroutines.launch
 import kotlinx.html.*
+import org.litote.kmongo.eq
 import starshipfights.CurrentConfiguration
 import starshipfights.data.Id
 import starshipfights.data.admiralty.Admiral
@@ -195,9 +196,8 @@ object TestAuthProvider : AuthProvider {
                                        val userAgent = request.userAgent()
                                        if (userAgent != null && credentials.name.isValidUsername() && credentials.password == TEST_PASSWORD) {
                                                sfLogger.info("Attempting to find user ${credentials.name}")
-                                               val user = //User.locate(User::username eq credentials.name)
-                                                       //?: User(username = credentials.name).also {
-                                                       User(username = credentials.name).also {
+                                               val user = User.locate(User::username eq credentials.name)
+                                                       ?: User(username = credentials.name).also {
                                                                sfLogger.info("Attempting to add user with name ${credentials.name}")
                                                                User.put(it)
                                                        }
index 2be671bf3e02403d0ff3c5474fcbb4b5a378f4bb..13f0de03f1de445ec173fba31b0a5f062ea83482 100644 (file)
@@ -10,6 +10,7 @@ import org.litote.kmongo.coroutine.coroutine
 import org.litote.kmongo.serialization.IdController
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
+import starshipfights.sfLogger
 import kotlin.coroutines.CoroutineContext
 import kotlin.reflect.KClass
 import kotlin.reflect.KProperty1
@@ -111,7 +112,12 @@ private class DocumentTableImpl<T : DataDocument<T>>(val kclass: KClass<T>, priv
        }
        
        override suspend fun locate(bson: Bson): T? {
-               return collection().findOne(bson)
+               try {
+                       return collection().findOne(bson)
+               } catch (ex: Exception) {
+                       sfLogger.error("Got exception from table ${kclass.simpleName}", ex)
+                       throw ex
+               }
        }
        
        override suspend fun update(where: Bson, set: Bson) {