2021-02-19 20:41:49 +01:00
|
|
|
package com.mrousavy.camera.utils
|
2021-02-19 16:28:14 +01:00
|
|
|
|
|
|
|
import com.facebook.react.bridge.*
|
|
|
|
|
|
|
|
private fun makeErrorCauseMap(throwable: Throwable): ReadableMap {
|
2021-02-26 10:56:20 +01:00
|
|
|
val map = Arguments.createMap()
|
|
|
|
map.putString("message", throwable.message)
|
|
|
|
map.putString("stacktrace", throwable.stackTraceToString())
|
|
|
|
if (throwable.cause != null) {
|
|
|
|
map.putMap("cause", makeErrorCauseMap(throwable.cause!!))
|
|
|
|
}
|
|
|
|
return map
|
2021-02-19 16:28:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun makeErrorMap(code: String? = null, message: String? = null, throwable: Throwable? = null, userInfo: WritableMap? = null): ReadableMap {
|
2021-02-26 10:56:20 +01:00
|
|
|
val map = Arguments.createMap()
|
|
|
|
map.putString("code", code)
|
|
|
|
map.putString("message", message)
|
|
|
|
map.putMap("cause", if (throwable != null) makeErrorCauseMap(throwable) else null)
|
|
|
|
map.putMap("userInfo", userInfo)
|
|
|
|
return map
|
2021-02-19 16:28:14 +01:00
|
|
|
}
|