Compare commits

...

4 Commits

Author SHA1 Message Date
662206f32f Merge pull request 'Task reportToDiscord throw an exception if http request is not sucessful' (#22) from dev into master
Some checks failed
/ build (17, ubuntu-latest) (push) Successful in 4m34s
/ deploy (17, ubuntu-latest) (push) Failing after 4m12s
Reviewed-on: #22
2023-07-26 23:25:15 +02:00
bb9ae4d59b Doesn't return an exception if 20X
Some checks reported warnings
/ deploy (17, ubuntu-latest) (push) Has been cancelled
/ build (17, ubuntu-latest) (push) Has been cancelled
/ deploy (17, ubuntu-latest) (pull_request) Has been cancelled
/ build (17, ubuntu-latest) (pull_request) Has been cancelled
2023-07-26 23:22:49 +02:00
18964aa779 Change exception to GradleException
Some checks reported warnings
/ deploy (17, ubuntu-latest) (push) Has been cancelled
/ build (17, ubuntu-latest) (push) Has been cancelled
2023-07-26 23:21:14 +02:00
5afbcd9ffe 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
2023-07-26 23:11:19 +02:00

View File

@ -2,6 +2,7 @@ package fr.altarik;
import okhttp3.*;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
@ -41,6 +42,9 @@ public abstract class ReportDiscord extends DefaultTask {
.build();
try(Response response = client.newCall(request).execute()) {
getLogger().info("report sent");
if(!response.isSuccessful()) {
throw new GradleException("Discord returned a " + response.code() + " code: " + response.message());
}
}
}