de.adorsys.multibanking.domain.exception.MultibankingException Maven / Gradle / Ivy
package de.adorsys.multibanking.domain.exception;
import de.adorsys.multibanking.domain.Message;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collections;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
public class MultibankingException extends RuntimeException {
private final int httpResponseCode;
private final List psuMessages;
private final List tppMessages;
private final MultibankingError multibankingError;
public MultibankingException(MultibankingError multibankingError) {
this(multibankingError, 400, Collections.emptyList(), Collections.emptyList());
}
public MultibankingException(MultibankingError multibankingError, int httpResponseCode, String psuMessage) {
this(multibankingError, httpResponseCode, Collections.singletonList(new Message(null, null, null, psuMessage, null)), Collections.emptyList()
);
}
public MultibankingException(MultibankingError multibankingError, String psuMessage) {
this(multibankingError, 400, Collections.singletonList(new Message(null, null, null, psuMessage, null)), Collections.emptyList()
);
}
public MultibankingException(MultibankingError multibankingError, List psuMessages) {
this(multibankingError, 400, psuMessages, Collections.emptyList());
}
public MultibankingException(MultibankingError multibankingError, int httpResponseCode, List psuMessages, List tppMessages) {
super(toExceptionString(psuMessages, tppMessages));
this.psuMessages = psuMessages;
this.multibankingError = multibankingError;
this.httpResponseCode = httpResponseCode;
this.tppMessages = tppMessages;
}
@Override
public String toString() {
return toExceptionString(psuMessages, tppMessages);
}
private static String toExceptionString(List psuMessages, List tppMessages) {
StringBuilder stringBuilder = new StringBuilder();
if (psuMessages != null) {
psuMessages.forEach(psuMessage -> stringBuilder.append(psuMessage.toString()).append("\\n"));
}
if (tppMessages != null) {
tppMessages.forEach(tppMessage -> stringBuilder.append(tppMessage.toString()).append("\\n"));
}
return stringBuilder.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy