Skip to content
Snippets Groups Projects
Commit 7c047508 authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Updated parsing of raw data

parent 02eefd3c
No related branches found
No related tags found
No related merge requests found
......@@ -17,11 +17,15 @@ inline fun <reified T: BindingsModel> parseModel(data: ByteArray?, error: Except
}
fun parseData(rawData: ByteArray?, error: Exception?): Result<ByteArray> {
return parseDataArray(rawData, error).run {
getOrNull()?.let {
Result.success(it.firstOrNull() ?: byteArrayOf())
} ?: Result.failure(exceptionOrNull() ?: InvalidDataException())
}
return error?.let {
Result.failure(it)
} ?: rawData?.let {
if (it.isNotEmpty()) {
Result.success(
it.decodeToString().fromBase64toByteArray()
)
} else Result.success(byteArrayOf())
} ?: Result.failure(InvalidDataException())
}
fun parseDataArray(dataArray: ByteArray?, error: Exception?): Result<List<ByteArray>> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment