]> git.basschouten.com Git - openhab-addons.git/blob
cfea1397f89995a5316a1078b974bfaeae433593
[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 FreeAtHomeHttpCommunicationException} is responsible for handling the communication exception to the SysAp
22  * via HTTP link
23  *
24  * @author Andras Uhrin - Initial contribution
25  *
26  */
27 @NonNullByDefault
28 public class FreeAtHomeHttpCommunicationException extends Exception {
29     private static final long serialVersionUID = -817364286035448863L;
30     private String errorMessage = "Unknown_Exception";
31     private int errorCode;
32
33     public FreeAtHomeHttpCommunicationException(int errorCode, String message) {
34         super(message);
35
36         this.errorMessage = message;
37         this.errorCode = errorCode;
38     }
39
40     public @Nullable String getMessage() {
41         return this.errorMessage;
42     }
43
44     public int getErrorCode() {
45         return this.errorCode;
46     }
47
48     @Override
49     public String toString() {
50         return "FreeAtHomeHttpCommunicationException [errorMessage=" + errorMessage + ", errorCode=" + errorCode + "]";
51     }
52
53     @Override
54     public int hashCode() {
55         return Objects.hash(errorCode, errorMessage);
56     }
57
58     @Override
59     public boolean equals(@Nullable Object obj) {
60         if (this == obj) {
61             return true;
62         }
63         if (obj == null) {
64             return false;
65         }
66         if (getClass() != obj.getClass()) {
67             return false;
68         }
69
70         FreeAtHomeHttpCommunicationException other = (FreeAtHomeHttpCommunicationException) obj;
71
72         return errorCode == other.errorCode && Objects.equals(errorMessage, other.errorMessage);
73     }
74 }