Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
  • Loading branch information
sowjanyakch committed Nov 14, 2024
1 parent 2c6daed commit 92caa21
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import retrofit2.HttpException
import java.util.Calendar
import java.util.Locale
import javax.inject.Inject
Expand Down Expand Up @@ -191,7 +192,11 @@ class SetStatusDialogFragment :
}

override fun onError(e: Throwable) {
Log.e(TAG, "Error while fetching predefined statuses", e)
if (e is HttpException && e.code() == HTTP_STATUS_CODE_NOT_FOUND) {
Log.d(TAG, "User does not have a backup status set")
} else {
Log.e(TAG, "Error while getting user backup status", e)
}
}

override fun onComplete() {
Expand Down Expand Up @@ -319,7 +324,7 @@ class SetStatusDialogFragment :
}
}
override fun onError(e: Throwable) {
Log.e(TAG, "Error while fetching predefined statuses", e)
Log.e(TAG, "Failed to revert user status", e)
}

override fun onComplete() {
Expand Down Expand Up @@ -585,7 +590,8 @@ class SetStatusDialogFragment :
Log.e(TAG, "failed to set PredefinedStatusMessage", e)
}

override fun onComplete() {
override fun onComplete() {
//unused atm
}
})
}
Expand Down Expand Up @@ -651,6 +657,7 @@ class SetStatusDialogFragment :
companion object {
private val TAG = SetStatusDialogFragment::class.simpleName
private const val HTTP_STATUS_CODE_OK = 200
private const val HTTP_STATUS_CODE_NOT_FOUND = 404

@JvmStatic
fun newInstance(status: Status): SetStatusDialogFragment {
Expand Down

0 comments on commit 92caa21

Please sign in to comment.