-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathRNRiveError.kt
More file actions
70 lines (65 loc) · 2.23 KB
/
RNRiveError.kt
File metadata and controls
70 lines (65 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.rivereactnative
import app.rive.runtime.kotlin.core.errors.*
enum class RNRiveError(private val mValue: String) {
FileNotFound("FileNotFound"),
UnsupportedRuntimeVersion("UnsupportedRuntimeVersion"),
IncorrectRiveFileUrl("IncorrectRiveFileUrl"),
IncorrectAnimationName("IncorrectAnimationName"),
MalformedFile("MalformedFile"),
IncorrectArtboardName("IncorrectArtboardName"),
IncorrectStateMachineName("IncorrectStateMachineName"),
IncorrectStateMachineInput("IncorrectStateMachineInput"),
TextRunNotFoundError("TextRunNotFoundError"),
DataBindingError("DataBindingError");
var message: String = "Default message"
override fun toString(): String {
return mValue
}
companion object {
fun mapToRNRiveError(ex: RiveException): RNRiveError? {
return when (ex) {
is ArtboardException -> {
val err = IncorrectArtboardName
err.message = ex.message ?: "Unknown artboard exception"
return err
}
is UnsupportedRuntimeVersionException -> {
val err = UnsupportedRuntimeVersion
err.message = ex.message ?: "Unsupported runtime version"
return err
}
is MalformedFileException -> {
val err = MalformedFile
err.message = ex.message ?: "Malformed file"
return err
}
is AnimationException -> {
val err = IncorrectAnimationName
err.message = ex.message ?: "Unknown animation exception"
return err
}
is StateMachineException -> {
val err = IncorrectStateMachineName
err.message = ex.message ?: "Unknown state machine exception"
return err
}
is StateMachineInputException -> {
val err = IncorrectStateMachineInput
err.message = ex.message ?: "Unknown state machine input exception"
return err
}
is TextValueRunException -> {
val err = TextRunNotFoundError
err.message = ex.message ?: "Text run not found"
return err
}
is ViewModelException -> {
val err = DataBindingError
err.message = ex.message ?: "Data binding error"
return err
}
else -> null
}
}
}
}