1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.health.connect.ratelimiter; 18 19 import android.annotation.Nullable; 20 import android.health.connect.HealthConnectException; 21 22 /** @hide */ 23 public class RateLimiterException extends HealthConnectException { 24 @RateLimiter.QuotaBucket.Type private final int mQuotaBucket; 25 private final float mQuotaLimit; 26 27 /** 28 * @param message The detailed error message. 29 * @param quotaBucket The rate limit bucket in which quota is exceeded. 30 * @param quotaLimit Api call limit for the bucket. 31 * @hide 32 */ RateLimiterException( @ullable String message, @RateLimiter.QuotaBucket.Type int quotaBucket, float quotaLimit)33 public RateLimiterException( 34 @Nullable String message, 35 @RateLimiter.QuotaBucket.Type int quotaBucket, 36 float quotaLimit) { 37 super(HealthConnectException.ERROR_RATE_LIMIT_EXCEEDED, message); 38 mQuotaBucket = quotaBucket; 39 mQuotaLimit = quotaLimit; 40 } 41 42 /** 43 * Returns rateLimiterQuotaBucket in which the quota is exceeded. Default of value zero 44 * represents an undefined quota bucket. 45 */ getRateLimiterQuotaBucket()46 public int getRateLimiterQuotaBucket() { 47 return mQuotaBucket; 48 } 49 50 /** Returns rateLimiter API call limit for the bucket. */ getRateLimiterQuotaLimit()51 public float getRateLimiterQuotaLimit() { 52 return mQuotaLimit; 53 } 54 } 55