Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error message when no repo is found #337

Merged
merged 2 commits into from May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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