[AB-258] improving handling of request failures for urban dictionary

This commit is contained in:
Sheldan
2021-05-12 15:38:57 +02:00
parent d4edbb0d94
commit eca9e6ebf7
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package dev.sheldan.abstracto.webservices.urban.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.templating.Templatable;
import dev.sheldan.abstracto.webservices.urban.model.exception.UrbanDictionaryRequestExceptionModel;
public class UrbanDictionaryRequestException extends AbstractoRunTimeException implements Templatable {
private final UrbanDictionaryRequestExceptionModel model;
public UrbanDictionaryRequestException(Integer responseCode) {
super(String.format("Request failure towards urban dictionary %s.", responseCode));
this.model = UrbanDictionaryRequestExceptionModel
.builder()
.responseCode(responseCode)
.build();
}
@Override
public String getTemplateName() {
return "urban_dictionary_request_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.webservices.urban.model.exception;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@Builder
public class UrbanDictionaryRequestExceptionModel implements Serializable {
private Integer responseCode;
}