mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Throw exception in okhttp coroutine if response isn't successful
This commit is contained in:
		| @@ -52,6 +52,11 @@ suspend fun Call.await(): Response { | ||||
|     return suspendCancellableCoroutine { continuation -> | ||||
|         enqueue(object : Callback { | ||||
|             override fun onResponse(call: Call, response: Response) { | ||||
|                 if (!response.isSuccessful) { | ||||
|                     continuation.resumeWithException(Exception("HTTP error ${response.code}")) | ||||
|                     return | ||||
|                 } | ||||
|  | ||||
|                 continuation.resume(response) | ||||
|             } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user