]> git.basschouten.com Git - openhab-addons.git/blob
4ebe669e6ca2df4f7e2238055dc6667b631859c9
[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.freebox.internal.api;
14
15 import org.openhab.binding.freebox.internal.api.model.FreeboxResponse;
16
17 /**
18  * Exception for errors when using the Freebox API
19  *
20  * @author Laurent Garnier - Initial contribution
21  */
22 public class FreeboxException extends Exception {
23
24     private static final long serialVersionUID = 1L;
25
26     protected FreeboxResponse<?> response;
27
28     public FreeboxException(String msg) {
29         this(msg, null, null);
30     }
31
32     public FreeboxException(String msg, Throwable cause) {
33         this(msg, cause, null);
34     }
35
36     public FreeboxException(String msg, FreeboxResponse<?> response) {
37         this(msg, null, response);
38     }
39
40     public FreeboxException(FreeboxResponse<?> response) {
41         this(response.getMsg(), null, response);
42     }
43
44     public FreeboxException(String msg, Throwable cause, FreeboxResponse<?> response) {
45         super(msg, cause);
46         this.response = response;
47     }
48
49     public FreeboxResponse<?> getResponse() {
50         return response;
51     }
52
53     public boolean isAuthRequired() {
54         return getResponse() != null && getResponse().isAuthRequired();
55     }
56
57     public boolean isMissingRights() {
58         return getResponse() != null && getResponse().isMissingRights();
59     }
60 }