Skip to content

Commit d4844f9

Browse files
committed
refactor: tweak error message for authorisation error in http request
1 parent 71f395c commit d4844f9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

embrace-gradle-plugin/src/main/java/io/embrace/android/gradle/plugin/tasks/HttpCallResultHandler.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,24 @@ fun handleHttpCallResult(
2121
failBuildOnUploadErrors: Boolean,
2222
) {
2323
val msg = when (result) {
24-
is Failure -> "failed: ${endpoint.url}, status=${result.code}"
24+
is Failure -> handleHttpFailure(endpoint, result)
2525
is Error -> "errored: ${endpoint.url}, stacktrace=${result.exception.stackTrace.joinToString("\n")}"
2626
is Success<*> -> null
2727
}
2828
if (msg != null && failBuildOnUploadErrors) {
2929
error("Embrace HTTP request $msg")
3030
}
3131
}
32+
33+
private fun handleHttpFailure(
34+
endpoint: EmbraceEndpoint,
35+
result: Failure,
36+
): String {
37+
val msg = "failed: ${endpoint.url}, status=${result.code}"
38+
39+
if (result.code == 403) {
40+
return "$msg. Please check that src/main/embrace-config.json contains an " +
41+
"app_id and api_token that match the settings page of your Embrace dashboard."
42+
}
43+
return msg
44+
}

0 commit comments

Comments
 (0)