You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/03/05 20:53:24 UTC
[incubator-plc4x] branch master updated: Another try to get rid of
that SonarQube warning
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/master by this push:
new 378e6d3 Another try to get rid of that SonarQube warning
378e6d3 is described below
commit 378e6d34d5fba5035ac321091ff302fbb3f90215
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Mar 5 21:53:20 2018 +0100
Another try to get rid of that SonarQube warning
---
.../java/api/exceptions/PlcRuntimeException.java | 44 ++++++++++++++++++++++
.../java/ads/netty/util/LittleEndianEncoder.java | 5 ++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcRuntimeException.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcRuntimeException.java
new file mode 100644
index 0000000..372d70f
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcRuntimeException.java
@@ -0,0 +1,44 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.plc4x.java.api.exceptions;
+
+/**
+ * Most generic type of plc4x runtime exception. All plc4x exceptions are derived from
+ * PlcException.
+ */
+public class PlcRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public PlcRuntimeException(String message) {
+ super(message);
+ }
+
+ public PlcRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PlcRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ public PlcRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/util/LittleEndianEncoder.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/util/LittleEndianEncoder.java
index 329d60b..4f69687 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/util/LittleEndianEncoder.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/util/LittleEndianEncoder.java
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.ads.netty.util;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.plc4x.java.ads.api.commands.types.TimeStamp;
import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -68,12 +69,12 @@ public class LittleEndianEncoder {
try {
bos.write(byteValue);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new PlcRuntimeException(e);
}
},
(a, b) -> {
}).toByteArray();
- } catch (RuntimeException e) {
+ } catch (PlcRuntimeException e) {
throw new PlcProtocolException("Error encoding data", e);
}
}
--
To stop receiving notification emails like this one, please contact
cdutz@apache.org.