Skip to content

Commit

Permalink
[tacmi] Additional changes from code review: Thread name, logging & e…
Browse files Browse the repository at this point in the history
…xception improvements

Signed-off-by: Christian Niessner <[email protected]>
  • Loading branch information
marvkis committed Sep 7, 2020
1 parent 6289423 commit 5f5bbed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.smarthome.core.thing.binding.BaseBridgeHandler;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.RefreshType;
import org.openhab.binding.tacmi.internal.TACmiBindingConstants;
import org.openhab.binding.tacmi.internal.message.AnalogMessage;
import org.openhab.binding.tacmi.internal.message.DigitalMessage;
import org.openhab.binding.tacmi.internal.message.Message;
Expand Down Expand Up @@ -168,8 +167,7 @@ public void initialize() {
return;
}

ReceiveThread reciveThreadNN = new ReceiveThread(
"OH-" + TACmiBindingConstants.BINDING_ID + "-" + getThing().getUID().getAsString());
ReceiveThread reciveThreadNN = new ReceiveThread("OH-binding-" + getThing().getUID().getAsString());
reciveThreadNN.setDaemon(true);
reciveThreadNN.start();
this.receiveThread = reciveThreadNN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,14 @@ private void getApiPageEntry(@Nullable String id2, int line, int col, String sho
URI uri = this.taCmiSchemaHandler.buildUri("INCLUDE/changerx2.cgi?sadrx2=" + address);
final ChangerX2Parser pp = this.taCmiSchemaHandler.parsePage(uri, new ChangerX2Parser(shortName));
cx2e = pp.getParsedEntry();
} catch (final ParseException | InterruptedException | TimeoutException | ExecutionException ex) {
logger.warn("Error loading API Scheme: {} ", ex.getMessage(), ex);
} catch (final ParseException | RuntimeException ex) {
logger.warn("Error parsing API Scheme: {} ", ex.getMessage(), ex);
} catch (final TimeoutException | InterruptedException | ExecutionException ex) {
logger.warn("Error loading API Scheme: {} ", ex.getMessage());
}
}
if (channel == null) {
logger.info("Creating / updating channel {} of type {} for '{}'", shortName, channelType, description);
logger.debug("Creating / updating channel {} of type {} for '{}'", shortName, channelType, description);
this.configChanged = true;
ChannelUID channelUID = new ChannelUID(this.taCmiSchemaHandler.getThing().getUID(), shortName);
ChannelBuilder channelBuilder = ChannelBuilder.create(channelUID, channelType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ private void refreshData() {
// binding shutdown is in progress
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE);
this.online = false;
} catch (final ParseException | TimeoutException | ExecutionException | RuntimeException e) {
// we need the stack trace here to get an idea what happened when this happens to somebody and we try to
// troubleshoot this
logger.debug("Error loading API Scheme: {} ", e.getMessage(), e);
} catch (final ParseException | RuntimeException e) {
logger.warn("Error parsing API Scheme: {} ", e.getMessage(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, "Error: " + e.getMessage());
this.online = false;
} catch (final TimeoutException | ExecutionException e) {
logger.warn("Error loading API Scheme: {} ", e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error: " + e.getMessage());
this.online = false;
}
Expand Down

0 comments on commit 5f5bbed

Please sign in to comment.