gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: error handling


From: gnunet
Subject: [libeufin] branch master updated: error handling
Date: Mon, 28 Nov 2022 19:13:40 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 87df1c6a error handling
87df1c6a is described below

commit 87df1c6a292a142d7599ae665d05b5a5ac59f279
Author: MS <ms@taler.net>
AuthorDate: Mon Nov 28 19:13:32 2022 +0100

    error handling
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
index ffcbe43c..0d968ce7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Scheduling.kt
@@ -24,6 +24,7 @@ import com.cronutils.model.time.ExecutionTime
 import com.cronutils.parser.CronParser
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
 import io.ktor.client.HttpClient
+import kotlinx.coroutines.CoroutineExceptionHandler
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.time.delay
@@ -35,6 +36,7 @@ import java.lang.IllegalArgumentException
 import java.time.Duration
 import java.time.Instant
 import java.time.ZonedDateTime
+import kotlin.system.exitProcess
 
 private data class TaskSchedule(
     val taskId: Long,
@@ -68,6 +70,9 @@ private suspend fun runTask(client: HttpClient, sched: 
TaskSchedule) {
         }
     } catch (e: Exception) {
         logger.error("Exception during task $sched", e)
+    } catch (so: StackOverflowError) {
+        logger.error(so.stackTraceToString())
+        exitProcess(1)
     }
 }
 
@@ -85,9 +90,16 @@ object NexusCron {
         CronParser(cronDefinition)
     }
 }
-
+/**
+ * Here to catch StackOverflowError and exit.  It is not clear however
+ * if this handler catches also the 'Error' type.
+ */
+val fallback = CoroutineExceptionHandler { _, err ->
+    logger.error(err.stackTraceToString())
+    exitProcess(1)
+}
 fun startOperationScheduler(httpClient: HttpClient) {
-    GlobalScope.launch {
+    GlobalScope.launch(fallback) {
         while (true) {
             // First, assign next execution time stamps to all tasks that need 
them
             transaction {
@@ -117,7 +129,6 @@ fun startOperationScheduler(httpClient: HttpClient) {
                     TaskSchedule(it.id.value, it.taskName, it.taskType, 
it.resourceType, it.resourceId, it.taskParams)
                 }
             }
-
             // Execute those due tasks
             dueTasks.forEach {
                 runTask(httpClient, it)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]