]> git.basschouten.com Git - openhab-addons.git/blob
c490db2f69104a8ecbf7795e5fc58a3ef74393ed
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.freeathomesystem.internal.util;
14
15 import java.util.Objects;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * The {@link FreeAtHomeGeneralException} is responsible for handling general exceptions in the free@home binding
22  *
23  * @author Andras Uhrin - Initial contribution
24  *
25  */
26 @NonNullByDefault
27 public class FreeAtHomeGeneralException extends Exception {
28     private static final long serialVersionUID = -835448863173642860L;
29     private String errorMessage = "Unknown_Exception";
30     private int errorCode = 0;
31
32     public FreeAtHomeGeneralException(int errorCode, String message) {
33         super(message);
34
35         this.errorMessage = message;
36         this.errorCode = errorCode;
37     }
38
39     public @Nullable String getMessage() {
40         return this.errorMessage;
41     }
42
43     public int getErrorCode() {
44         return this.errorCode;
45     }
46
47     @Override
48     public String toString() {
49         return "FreeAtHomeHttpCommunicationException [errorMessage=" + errorMessage + ", errorCode=" + errorCode + "]";
50     }
51
52     @Override
53     public int hashCode() {
54         return Objects.hash(errorCode, errorMessage);
55     }
56
57     @Override
58     public boolean equals(@Nullable Object obj) {
59         if (this == obj) {
60             return true;
61         }
62         if (obj == null) {
63             return false;
64         }
65         if (getClass() != obj.getClass()) {
66             return false;
67         }
68
69         FreeAtHomeGeneralException other = (FreeAtHomeGeneralException) obj;
70
71         return errorCode == other.errorCode && Objects.equals(errorMessage, other.errorMessage);
72     }
73 }