improve error handling (#9543)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
parent
94d07217d0
commit
facb984b05
|
@ -22,6 +22,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||
@NonNullByDefault
|
||||
public class Tr064CommunicationException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String soapError = "";
|
||||
private int httpError = 0;
|
||||
|
||||
public Tr064CommunicationException(Exception e) {
|
||||
super(e);
|
||||
|
@ -30,4 +32,18 @@ public class Tr064CommunicationException extends Exception {
|
|||
public Tr064CommunicationException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public Tr064CommunicationException(String s, Integer httpError, String soapError) {
|
||||
super(s);
|
||||
this.httpError = httpError;
|
||||
this.soapError = soapError;
|
||||
};
|
||||
|
||||
public String getSoapError() {
|
||||
return soapError;
|
||||
}
|
||||
|
||||
public int getHttpError() {
|
||||
return httpError;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class SOAPConnector {
|
|||
String soapReason = getSOAPElement(soapMessage, "errorDescription").orElse("unknown");
|
||||
String error = String.format("HTTP-Response-Code %d (%s), SOAP-Fault: %s (%s)",
|
||||
response.getStatus(), response.getReason(), soapError, soapReason);
|
||||
throw new Tr064CommunicationException(error);
|
||||
throw new Tr064CommunicationException(error, response.getStatus(), soapError);
|
||||
}
|
||||
return soapMessage;
|
||||
}
|
||||
|
@ -248,7 +248,17 @@ public class SOAPConnector {
|
|||
.orElseThrow(() -> new Tr064CommunicationException("failed to transform '"
|
||||
+ channelConfig.getChannelTypeDescription().getGetAction().getArgument() + "'"));
|
||||
} catch (Tr064CommunicationException e) {
|
||||
logger.info("Failed to get {}: {}", channelConfig, e.getMessage());
|
||||
if (e.getHttpError() == 500) {
|
||||
switch (e.getSoapError()) {
|
||||
case "714":
|
||||
// NoSuchEntryInArray usually is an unknown entry in the MAC list
|
||||
logger.debug("Failed to get {}: {}", channelConfig, e.getMessage());
|
||||
return UnDefType.UNDEF;
|
||||
default:
|
||||
}
|
||||
}
|
||||
// all other cases are an error
|
||||
logger.warn("Failed to get {}: {}", channelConfig, e.getMessage());
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue