task throw an exception when response isn't a 200 code
All checks were successful
/ build (17, ubuntu-latest) (push) Successful in 4m58s
/ deploy (17, ubuntu-latest) (push) Has been skipped

This commit is contained in:
Quentin Legot 2023-07-26 23:11:19 +02:00
parent 23236ac2dc
commit 5afbcd9ffe

View File

@ -5,6 +5,7 @@ import org.gradle.api.DefaultTask;
import org.gradle.api.provider.Property; import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.internal.impldep.org.apache.http.client.HttpResponseException;
import java.io.IOException; import java.io.IOException;
@ -41,6 +42,9 @@ public abstract class ReportDiscord extends DefaultTask {
.build(); .build();
try(Response response = client.newCall(request).execute()) { try(Response response = client.newCall(request).execute()) {
getLogger().info("report sent"); getLogger().info("report sent");
if(!(response.code() == 200)) {
throw new HttpResponseException(response.code(), response.message());
}
} }
} }