From c4c076f3e58bbe27e19651a18606a958ca31b0f9 Mon Sep 17 00:00:00 2001 From: Hiroyuki Kusu Date: Thu, 12 Dec 2024 23:04:17 +0900 Subject: [PATCH] Fix error handling bug --- .../kotlin/io/yumemi/tart/core/TartStore.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tart-core/src/commonMain/kotlin/io/yumemi/tart/core/TartStore.kt b/tart-core/src/commonMain/kotlin/io/yumemi/tart/core/TartStore.kt index 8f9ef9e..5741d46 100644 --- a/tart-core/src/commonMain/kotlin/io/yumemi/tart/core/TartStore.kt +++ b/tart-core/src/commonMain/kotlin/io/yumemi/tart/core/TartStore.kt @@ -85,7 +85,7 @@ open class TartStore internal constructor( processMiddleware { onInit(this@TartStore, coroutineScope.coroutineContext) } onStateEntered(initialState) } catch (t: Throwable) { - if (t is MiddlewareError) { + if (t is InternalError) { throw t.original } throw t @@ -110,7 +110,7 @@ open class TartStore internal constructor( onStateEntered(nextState) } } catch (t: Throwable) { - if (t is MiddlewareError) { + if (t is InternalError) { throw t.original } onErrorOccurred(currentState, t) @@ -133,7 +133,7 @@ open class TartStore internal constructor( onStateEntered(nextState, inErrorHandling = inErrorHandling) } } catch (t: Throwable) { - if (t is MiddlewareError) { + if (t is InternalError) { throw t.original } if (inErrorHandling) { @@ -159,7 +159,7 @@ open class TartStore internal constructor( onStateEntered(nextState, inErrorHandling = true) } } catch (t: Throwable) { - if (t is MiddlewareError) { + if (t is InternalError) { throw t.original } throw t @@ -192,7 +192,7 @@ open class TartStore internal constructor( try { latestState(nextState) } catch (t: Throwable) { - onError(t) + throw InternalError(t) } processMiddleware { afterStateChange(nextState, state) } } @@ -218,9 +218,9 @@ open class TartStore internal constructor( } } } catch (t: Throwable) { - throw MiddlewareError(t) + throw InternalError(t) } } - private class MiddlewareError(val original: Throwable) : Throwable(original) + private class InternalError(val original: Throwable) : Throwable(original) }