Skip to content

Commit

Permalink
fix error message when no repo is found (#337)
Browse files Browse the repository at this point in the history
* fix error message when no repo is found

* add username to other error messages
  • Loading branch information
gabrielittner committed May 27, 2022
1 parent 6134aa0 commit 8e1f12d
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -7,7 +7,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory

internal class Nexus(
baseUrl: String,
username: String,
private val username: String,
password: String,
private val stagingRepository: String?
) {
Expand All @@ -28,7 +28,7 @@ internal class Nexus(
val profileRepositoriesResponse = service.getProfileRepositories().execute()

if (!profileRepositoriesResponse.isSuccessful) {
throw IOException("Cannot get profileRepositories: ${profileRepositoriesResponse.errorBody()?.string()}")
throw IOException("Cannot get profileRepositories for account $username: ${profileRepositoriesResponse.errorBody()?.string()}")
}

return profileRepositoriesResponse.body()?.data
Expand All @@ -38,7 +38,7 @@ internal class Nexus(
val allRepositories = getProfileRepositories() ?: emptyList()

if (allRepositories.isEmpty()) {
throw IllegalArgumentException("No staging repository prefixed with. Make sure you called \"./gradlew publish\".")
throw IllegalArgumentException("No staging repositories found in account $username. Make sure you called \"./gradlew publish\".")
}

val candidateRepositories = if (stagingRepository != null) {
Expand All @@ -49,15 +49,15 @@ internal class Nexus(

if (candidateRepositories.isEmpty()) {
throw IllegalArgumentException(
"No matching staging repository found. You can can explicitly choose one by " +
"No matching staging repository found in account $username. You can can explicitly choose one by " +
"passing it as an option like this \"./gradlew closeAndReleaseRepository --repository=comexample-123\". " +
"Available repositories are: ${allRepositories.joinToString(separator = ", ") { it.repositoryId }}"
)
}

if (candidateRepositories.size > 1) {
throw IllegalArgumentException(
"More than 1 matching staging repository found. You can can explicitly choose " +
"More than 1 matching staging repository found in account $username. You can can explicitly choose " +
"one by passing it as an option like this \"./gradlew closeAndReleaseRepository --repository comexample-123\". " +
"Available repositories are: ${allRepositories.joinToString(separator = ", ") { it.repositoryId }}"
)
Expand Down

0 comments on commit 8e1f12d

Please sign in to comment.