]> git.basschouten.com Git - openhab-addons.git/blob
ed5fa1f310f229076a24ff2fe7366e80c59a3234
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.mybmw.internal.handler.backend;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The {@link NetworkException} Data Transfer Object
20  *
21  * @author Bernd Weymann - Initial contribution
22  * @author Martin Grassl - extend Exception
23  */
24 @NonNullByDefault
25 public class NetworkException extends Exception {
26
27     private static final long serialVersionUID = 123L;
28
29     private String url = "";
30     private int status = -1;
31     private String reason = "";
32     private String body = "";
33
34     public NetworkException() {
35     }
36
37     public NetworkException(String url, int status, @Nullable String reason, @Nullable String body) {
38         this.url = url;
39         this.status = status;
40         this.reason = reason != null ? reason : "";
41         this.body = body != null ? body : "";
42     }
43
44     public NetworkException(String url, int status, @Nullable String reason, @Nullable String body, Throwable cause) {
45         super(cause);
46         this.url = url;
47         this.status = status;
48         this.reason = reason != null ? reason : "";
49         this.body = body != null ? body : "";
50     }
51
52     public NetworkException(String message) {
53         super(message);
54         this.reason = message;
55     }
56
57     public NetworkException(Throwable cause) {
58         super(cause);
59     }
60
61     public NetworkException(String message, Throwable cause) {
62         super(message, cause);
63         this.reason = message;
64     }
65
66     public String getUrl() {
67         return url;
68     }
69
70     public void setUrl(String url) {
71         this.url = url;
72     }
73
74     public int getStatus() {
75         return status;
76     }
77
78     public void setStatus(int status) {
79         this.status = status;
80     }
81
82     public String getReason() {
83         return reason;
84     }
85
86     public void setReason(String reason) {
87         this.reason = reason;
88     }
89
90     public String getBody() {
91         return body;
92     }
93
94     public void setBody(String body) {
95         this.body = body;
96     }
97
98     @Override
99     public String toString() {
100         return "NetworkException [url=" + url + ", status=" + status + ", reason=" + reason + ", body=" + body + "]";
101     }
102 }