]> git.basschouten.com Git - openhab-addons.git/blob
ab37e7349f9d792880f2804dba470e56d770f6f3
[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.openuv.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * Will be thrown for cloud errors
19  *
20  * @author GaĆ«l L'hopital - Initial contribution
21  */
22 @NonNullByDefault
23 public class OpenUVException extends Exception {
24     private static final long serialVersionUID = -1411477662081482350L;
25     private static final String ERROR_QUOTA_EXCEEDED = "Daily API quota exceeded";
26     private static final String ERROR_WRONG_KEY = "User with API Key not found";
27
28     public OpenUVException(String message) {
29         super(message);
30     }
31
32     private boolean checkMatches(String message) {
33         String currentMessage = getMessage();
34         return currentMessage != null && currentMessage.startsWith(message);
35     }
36
37     public boolean isApiKeyError() {
38         return checkMatches(ERROR_WRONG_KEY);
39     }
40
41     public boolean isQuotaError() {
42         return checkMatches(ERROR_QUOTA_EXCEEDED);
43     }
44 }