Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mahdibohloul/kpring-mediatr/feature/notif…
…ication-exception-handler Notification error handling
- Loading branch information
Showing
11 changed files
with
223 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/io/mahdibohloul/kpringmediator/core/FactoryExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.mahdibohloul.kpringmediator.core | ||
|
||
import io.mahdibohloul.kpringmediator.infrastructure.DefaultFactory | ||
|
||
fun DefaultFactory.enableNotificationExceptionHandling(): DefaultFactory { | ||
this.handleNotificationExceptions = true | ||
return this | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/io/mahdibohloul/kpringmediator/core/NotificationExceptionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.mahdibohloul.kpringmediator.core | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
/** | ||
* This class is responsible for handling exceptions thrown during the handling published notification. | ||
* @author Mahdi Bohloul | ||
* @param TException the type of the exception that will be handled | ||
* @param TNotification the type of the notification that will be handled | ||
*/ | ||
interface NotificationExceptionHandler< | ||
in TNotification : Notification, | ||
in TException : Exception> { | ||
suspend fun handle(notification: TNotification, exception: TException) | ||
|
||
fun getCoroutineDispatcher(): CoroutineDispatcher { | ||
return Dispatchers.Default | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.