mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[smhi] Catch exception that could cause binding to stop updating channels (#10794)
Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
This commit is contained in:
parent
d36c7804d0
commit
d454fe3331
@ -15,6 +15,7 @@ package org.openhab.binding.smhi.internal;
|
|||||||
import static org.openhab.binding.smhi.internal.SmhiBindingConstants.*;
|
import static org.openhab.binding.smhi.internal.SmhiBindingConstants.*;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
@ -26,6 +27,8 @@ import org.eclipse.jetty.client.api.Request;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for handling http requests to Smhi's API and return values.
|
* Class for handling http requests to Smhi's API and return values.
|
||||||
*
|
*
|
||||||
@ -88,7 +91,11 @@ public class SmhiConnector {
|
|||||||
logger.debug("Received response with status {} - {}", resp.getStatus(), resp.getReason());
|
logger.debug("Received response with status {} - {}", resp.getStatus(), resp.getReason());
|
||||||
switch (resp.getStatus()) {
|
switch (resp.getStatus()) {
|
||||||
case 200:
|
case 200:
|
||||||
return Parser.parseTimeSeries(resp.getContentAsString());
|
try {
|
||||||
|
return Parser.parseTimeSeries(resp.getContentAsString());
|
||||||
|
} catch (JsonParseException | DateTimeParseException e) {
|
||||||
|
throw new SmhiException(e);
|
||||||
|
}
|
||||||
case 400:
|
case 400:
|
||||||
case 404:
|
case 404:
|
||||||
throw new PointOutOfBoundsException();
|
throw new PointOutOfBoundsException();
|
||||||
|
Loading…
Reference in New Issue
Block a user