@@ -10,6 +10,7 @@ import com.rive.RiveReactNativeView
1010import com.rive.ViewConfiguration
1111import app.rive.runtime.kotlin.core.Fit as RiveFit
1212import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
13+ import app.rive.runtime.kotlin.core.errors.*
1314import kotlinx.coroutines.Dispatchers
1415import kotlinx.coroutines.withContext
1516
@@ -225,16 +226,14 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() {
225226 }
226227
227228 private fun detectErrorType (exception : Exception ): RiveErrorType {
228- val errorMessage = exception.message?.lowercase() ? : " "
229-
230- return when {
231- errorMessage.contains(" artboard" ) -> RiveErrorType .INCORRECTARTBOARDNAME
232- errorMessage.contains(" state machine" ) -> RiveErrorType .INCORRECTSTATEMACHINENAME
233- errorMessage.contains(" animation" ) -> RiveErrorType .INCORRECTANIMATIONNAME
234- errorMessage.contains(" data binding" ) || errorMessage.contains(" databinding" ) -> RiveErrorType .DATABINDINGERROR
235- errorMessage.contains(" text run" ) -> RiveErrorType .TEXTRUNNOTFOUNDERROR
236- errorMessage.contains(" file" ) || errorMessage.contains(" not found" ) -> RiveErrorType .FILENOTFOUND
237- errorMessage.contains(" malformed" ) || errorMessage.contains(" corrupt" ) -> RiveErrorType .MALFORMEDFILE
229+ return when (exception) {
230+ is ArtboardException -> RiveErrorType .INCORRECTARTBOARDNAME
231+ is StateMachineException -> RiveErrorType .INCORRECTSTATEMACHINENAME
232+ is AnimationException -> RiveErrorType .INCORRECTANIMATIONNAME
233+ is MalformedFileException -> RiveErrorType .MALFORMEDFILE
234+ is StateMachineInputException -> RiveErrorType .INCORRECTANIMATIONNAME
235+ is TextValueRunException -> RiveErrorType .TEXTRUNNOTFOUNDERROR
236+ is ViewModelException -> RiveErrorType .DATABINDINGERROR
238237 else -> RiveErrorType .UNKNOWN
239238 }
240239 }
0 commit comments