2 * Copyright (c) 2010-2023 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.openuv.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * Will be thrown for cloud errors
20 * @author Gaƫl L'hopital - Initial contribution
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";
28 public OpenUVException(String message) {
32 private boolean checkMatches(String message) {
33 String currentMessage = getMessage();
34 return currentMessage != null && currentMessage.startsWith(message);
37 public boolean isApiKeyError() {
38 return checkMatches(ERROR_WRONG_KEY);
41 public boolean isQuotaError() {
42 return checkMatches(ERROR_QUOTA_EXCEEDED);