Avoid crash in NodeRepository.

- The crash was happening due to an unhandled exception, the problem was that the statement that was raising an exception was out of the try/catch block.
This commit is contained in:
Severiano Jaramillo 2019-09-27 17:50:32 -05:00
parent 405344aa07
commit ed5cdb6d49

View file

@ -86,8 +86,8 @@ class NodeRepository(private val nodeDao: NodeDao) {
val updatePeriod = Constants.NODES_UPDATE_PERIOD val updatePeriod = Constants.NODES_UPDATE_PERIOD
// Verify if nodes list should be updated // Verify if nodes list should be updated
if (now - updatePeriod > lastUpdate) { if (now - updatePeriod > lastUpdate) {
val response = mBitsyWebservice?.getNodes()
try { try {
val response = mBitsyWebservice?.getNodes()
// Update the list of nodes only if we got at least MIN_NODES_SIZE nodes // Update the list of nodes only if we got at least MIN_NODES_SIZE nodes
if (response?.isSuccessful == true && (response.body()?.size ?: 0) >= MIN_NODES_SIZE) { if (response?.isSuccessful == true && (response.body()?.size ?: 0) >= MIN_NODES_SIZE) {
val nodesWS = response.body() ?: return val nodesWS = response.body() ?: return