Browse Source

update readme, add error logging

main
James Fenn 1 year ago
parent
commit
17ac9060e3
2 changed files with 4 additions and 2 deletions
  1. +1
    -1
      README.md
  2. +3
    -1
      gitrest/src/commonMain/kotlin/me/jfenn/gitrest/RequestProviderDelegate.kt

+ 1
- 1
README.md View File

@@ -40,7 +40,7 @@ To add the dependency to a module, copy this line into your app's build.gradle f
implementation "dev.horrific.code.james.git-rest-wrapper:gitrest-jvm:$gitrest_version"
```

The Android dependency can be imported similarly, using the `-android` dependency instead of `-jvm` (this isn't strictly necessary, but it does exclude a couple dependencies in place of Android APIs, reducing your overall APK size).
The Android dependency can be imported similarly, using the root `gitrest` dependency instead of `gitrest-jvm`. Gradle should identify & download the `gitrest-android` variant automatically? Either way, if you specify `gitrest-android` explicitly, your project won't compile. I don't know why this happens, only that I've spent far too long working this out and have other things to do.

```groovy
implementation "dev.horrific.code.james.git-rest-wrapper:gitrest-android:$gitrest_version"


+ 3
- 1
gitrest/src/commonMain/kotlin/me/jfenn/gitrest/RequestProviderDelegate.kt View File

@@ -9,7 +9,8 @@ import me.jfenn.gitrest.model.*

class RequestProviderDelegate(
private val services: Array<ServiceBuilder<*>> = arrayOf(GithubProvider, GitlabProvider, GiteaProvider),
private val strictMode: Boolean = false
private val strictMode: Boolean = false,
private val logError: (String) -> Unit = { println(it) } // TODO: implement a more robust log handler + check BuildConfig.DEBUG before logging
) : RequestProvider {

private val providers: MutableMap<String, RequestProvider> = HashMap()
@@ -34,6 +35,7 @@ class RequestProviderDelegate(
}
} catch (e: Exception) {
if (strictMode) throw e
else logError("GIT-REST: Error fetching ${str}: ${e::class.simpleName} - ${e.message}")
null
}
}


Loading…
Cancel
Save