]> git.basschouten.com Git - openhab-addons.git/blob
faee172ec92e313548428e7f36051d46cc49d91a
[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.ecovacs.internal.api;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jetty.client.api.Response;
17
18 /**
19  * @author Danny Baumann - Initial contribution
20  */
21 @NonNullByDefault
22 public class EcovacsApiException extends Exception {
23     private static final long serialVersionUID = -5903398729974682356L;
24     public final boolean isAuthFailure;
25
26     public EcovacsApiException(String reason) {
27         this(reason, false);
28     }
29
30     public EcovacsApiException(String reason, boolean isAuthFailure) {
31         super(reason);
32         this.isAuthFailure = isAuthFailure;
33     }
34
35     public EcovacsApiException(Response response) {
36         super("HTTP status " + response.getStatus());
37         isAuthFailure = response.getStatus() == 401;
38     }
39
40     public EcovacsApiException(Throwable cause) {
41         this(cause, false);
42     }
43
44     public EcovacsApiException(Throwable cause, boolean isAuthFailure) {
45         super(cause);
46         this.isAuthFailure = isAuthFailure;
47     }
48 }