2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.freeathomesystem.internal.util;
15 import java.util.Objects;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * The {@link FreeAtHomeGeneralException} is responsible for handling general exceptions in the free@home binding
23 * @author Andras Uhrin - Initial contribution
27 public class FreeAtHomeGeneralException extends Exception {
28 private static final long serialVersionUID = -835448863173642860L;
29 private String errorMessage = "Unknown_Exception";
30 private int errorCode = 0;
32 public FreeAtHomeGeneralException(int errorCode, String message) {
35 this.errorMessage = message;
36 this.errorCode = errorCode;
39 public @Nullable String getMessage() {
40 return this.errorMessage;
43 public int getErrorCode() {
44 return this.errorCode;
48 public String toString() {
49 return "FreeAtHomeHttpCommunicationException [errorMessage=" + errorMessage + ", errorCode=" + errorCode + "]";
53 public int hashCode() {
54 return Objects.hash(errorCode, errorMessage);
58 public boolean equals(@Nullable Object obj) {
65 if (getClass() != obj.getClass()) {
69 FreeAtHomeGeneralException other = (FreeAtHomeGeneralException) obj;
71 return errorCode == other.errorCode && Objects.equals(errorMessage, other.errorMessage);