Skip to content

Commit ea5318c

Browse files
Merge pull request #45 from Omega-R/develop
New release 1.4.3
2 parents 2cdd31d + 4b452cf commit ea5318c

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

core/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ dependencies {
5959
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kotlinCorutines_version}"
6060
implementation "org.jetbrains.kotlin:kotlin-android-extensions-runtime:${kotlin_version}"
6161

62-
api 'com.github.Omega-R.OmegaMoxy:moxy:2.2.0'
63-
api 'com.github.Omega-R.OmegaMoxy:moxy-androidx:2.2.0'
64-
api 'com.github.Omega-R.OmegaMoxy:moxy-ktx:2.2.0'
65-
kapt 'com.github.Omega-R.OmegaMoxy:moxy-compiler:2.2.0'
62+
api 'com.github.Omega-R.OmegaMoxy:moxy:2.2.1'
63+
api 'com.github.Omega-R.OmegaMoxy:moxy-androidx:2.2.1'
64+
api 'com.github.Omega-R.OmegaMoxy:moxy-ktx:2.2.1'
65+
kapt 'com.github.Omega-R.OmegaMoxy:moxy-compiler:2.2.1'
6666

6767

6868
api "com.github.Omega-R.OmegaRecyclerView:omegarecyclerview:${omegaRecyclerView}@aar"
69-
api 'com.github.Omega-R.OmegaTypes:glide:2.0.3'
69+
api 'com.github.Omega-R.OmegaTypes:glide:2.1.0'
7070
api 'com.github.Omega-R.OmegaIntentBuilder:core:1.3.3'
7171
api 'com.github.Omega-R:OmegaLaunchers:1.0.3'
7272
api 'com.github.Omega-R:OmegaExtensions:1.0.5'

core/src/main/java/com/omega_r/base/data/OmegaBaseRepository.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,7 @@ open class OmegaBaseRepository<SOURCE : Source>(
311311

312312
private suspend fun <R> ProducerScope<R>.applyMock(block: suspend SOURCE.() -> R) {
313313
if (mockSource != null) {
314-
getException {
315-
send(block(mockSource))
316-
return
317-
}
314+
send(block(mockSource))
318315
}
319316
}
320317

core/src/main/java/com/omega_r/base/errors/ErrorHandler.kt

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ package com.omega_r.base.errors
22

33
import kotlinx.coroutines.CoroutineExceptionHandler
44
import retrofit2.HttpException
5+
import retrofit2.Invocation
56
import java.net.ConnectException
6-
import java.net.HttpURLConnection.*
7+
import java.net.HttpURLConnection.HTTP_BAD_REQUEST
8+
import java.net.HttpURLConnection.HTTP_FORBIDDEN
9+
import java.net.HttpURLConnection.HTTP_INTERNAL_ERROR
10+
import java.net.HttpURLConnection.HTTP_NOT_FOUND
11+
import java.net.HttpURLConnection.HTTP_UNAUTHORIZED
12+
import java.net.HttpURLConnection.HTTP_UNAVAILABLE
713
import java.net.SocketTimeoutException
814
import java.net.UnknownHostException
915
import kotlin.coroutines.CoroutineContext
@@ -16,19 +22,24 @@ open class ErrorHandler : (Throwable) -> Exception, CoroutineExceptionHandler {
1622
override val key: CoroutineContext.Key<*>
1723
get() = CoroutineExceptionHandler
1824

19-
protected open fun handleHttpException(httpException: HttpException): AppException {
25+
protected open fun handleHttpException(httpException: HttpException, method: String?): AppException {
2026
val response = httpException.response()
2127

2228
when (response?.code()) {
2329
HTTP_INTERNAL_ERROR -> return AppException.ServerProblem(
24-
"Internal server error",
30+
"Internal server error\n$method",
2531
httpException
2632
)
27-
HTTP_BAD_REQUEST -> return AppException.ServerProblem("Bad request", httpException)
28-
HTTP_UNAVAILABLE -> return AppException.ServerProblem("Service Unavailable", httpException)
29-
HTTP_NOT_FOUND -> return AppException.NotFound("Not found", httpException)
30-
HTTP_FORBIDDEN -> return AppException.AccessDenied("Forbidden", httpException)
31-
HTTP_UNAUTHORIZED-> return AppException.NotAuthorized("Unauthorized", httpException)
33+
HTTP_BAD_REQUEST -> return AppException.ServerProblem("Bad request\n" +
34+
"$method", httpException)
35+
HTTP_UNAVAILABLE -> return AppException.ServerProblem("Service Unavailable\n" +
36+
"$method", httpException)
37+
HTTP_NOT_FOUND -> return AppException.NotFound("Not found\n" +
38+
"$method", httpException)
39+
HTTP_FORBIDDEN -> return AppException.AccessDenied("Forbidden\n" +
40+
"$method", httpException)
41+
HTTP_UNAUTHORIZED-> return AppException.NotAuthorized("Unauthorized\n" +
42+
"$method", httpException)
3243
}
3344

3445
return AppException.UnknownError("Unknown error type", httpException)
@@ -39,12 +50,27 @@ open class ErrorHandler : (Throwable) -> Exception, CoroutineExceptionHandler {
3950
is UnknownHostException -> AppException.NoConnection(null, throwable)
4051
is ConnectException,
4152
is SocketTimeoutException -> AppException.ServerUnavailable(null, throwable)
42-
is HttpException -> handleHttpException(throwable)
53+
is HttpException -> {
54+
handleHttpException(throwable, throwable.getMethod())
55+
}
4356
is AppException -> throwable
4457
else -> AppException.UnknownError("Unknown error", throwable)
4558
}
4659
}
4760

61+
protected open fun HttpException.getMethod(): String? {
62+
return response()?.raw()?.request()?.let {
63+
var result = "@" + it.method() + "(" + it.url().url().toString() + ") "
64+
65+
it.tag(Invocation::class.java)?.let { tag ->
66+
val arguments = tag.arguments().joinToString()
67+
result += tag.method().declaringClass.simpleName + "." + tag.method().name + "(" + arguments + ")"
68+
}
69+
70+
result
71+
}
72+
}
73+
4874
override fun handleException(context: CoroutineContext, exception: Throwable) {
4975
throw handleThrowable(exception)
5076
}

0 commit comments

Comments
 (0)