Skip to content

Commit

Permalink
timedout catch pulljob
Browse files Browse the repository at this point in the history
  • Loading branch information
harrynull committed Dec 24, 2018
1 parent 66f72e4 commit f4756c4
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ class PullDataJob : JobService() {

override fun onResponse(call: Call, response: Response) {
try {
val strMessage = response.body()!!.string().replace("\n", "")
val strMessage = try{
response.body()!!.string().replace("\n", "")
}catch(e: Exception){
Log.d("PullDataJob", "Job Finished Early ${e.message}")
jobFinished(params, true)
return
}
response.close()
if (strMessage.contains("Something went wrong!") // incorrect username or password
|| !strMessage.contains("{")) { // unknown error
Expand All @@ -166,11 +172,18 @@ class PullDataJob : JobService() {
jobFinished(params, false)
return
}
val oldData = utils.readDataArrayList()
try {
val oldData = utils.readDataArrayList()

diffSubjects(oldData.subjects, newData.subjects)
diffAttendances(oldData.attendances, newData.attendances)
diffSubjects(oldData.subjects, newData.subjects)
diffAttendances(oldData.attendances, newData.attendances)

}catch(e: Exception){
e.printStackTrace()
Log.d("PullDataJob", "Job Finished Early ${e.message}")
jobFinished(params, false)
return
}
Log.d("PullDataJob", "Job Finished Normally")
jobFinished(params, false)
} catch (e: Exception) {
Expand Down

0 comments on commit f4756c4

Please sign in to comment.