Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Nov 22, 2024
1 parent 71621bb commit 7fe4527
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ format:
dart format .

.PHONY: lint
## Apply automated fixes to Dart source code.
## Apply automated fixes to Dart source code and analyze the source code.
lint:
dart fix --apply
dart fix --apply && dart analyze
54 changes: 27 additions & 27 deletions lib/src/errors/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class LimitExceededException extends SdkException {
static String _generateMessageFromMetadata(
MomentoErrorTransportDetails? transportDetails, String message) {
String messageWrapper =
LimitExceededMessageWrapper.UNKNOWN_LIMIT_EXCEEDED.toString();
LimitExceededMessageWrapper.unknownLimitExceeded.toString();
if (transportDetails != null && transportDetails.grpc.metadata != null) {
var metadata = transportDetails.grpc.metadata;
String errorCause = metadata?.metadata["err"] ?? '';
Expand Down Expand Up @@ -317,15 +317,15 @@ SdkException grpcStatusToSdkException(GrpcError grpcError) {
}

enum LimitExceededMessageWrapper {
TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED(
topicSubscriptionsLimitExceeded(
"Topic subscriptions limit exceeded for this account"),
OPERATIONS_RATE_LIMIT_EXCEEDED(
operationsRateLimitExceeded(
"Request rate limit exceeded for this account"),
THROUGHPUT_RATE_LIMIT_EXCEEDED("Bandwidth limit exceeded for this account"),
REQUEST_SIZE_LIMIT_EXCEEDED("Request size limit exceeded for this account"),
ITEM_SIZE_LIMIT_EXCEEDED("Item size limit exceeded for this account"),
ELEMENT_SIZE_LIMIT_EXCEEDED("Element size limit exceeded for this account"),
UNKNOWN_LIMIT_EXCEEDED("Limit exceeded for this account");
throughputRateLimitExceeded("Bandwidth limit exceeded for this account"),
requestSizeLimitExceeded("Request size limit exceeded for this account"),
itemSizeLimitExceeded("Item size limit exceeded for this account"),
elementSizeLimitExceeded("Element size limit exceeded for this account"),
unknownLimitExceeded("Limit exceeded for this account");

final String messageWrapper;

Expand All @@ -339,18 +339,18 @@ enum LimitExceededMessageWrapper {
static LimitExceededMessageWrapper fromErrorCause(
String errorCause, String message) {
switch (errorCause) {
case "topic_subscriptions_limit_exceeded":
return LimitExceededMessageWrapper.TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED;
case "operations_rate_limit_exceeded":
return LimitExceededMessageWrapper.OPERATIONS_RATE_LIMIT_EXCEEDED;
case "throughput_rate_limit_exceeded":
return LimitExceededMessageWrapper.THROUGHPUT_RATE_LIMIT_EXCEEDED;
case "request_size_limit_exceeded":
return LimitExceededMessageWrapper.REQUEST_SIZE_LIMIT_EXCEEDED;
case "item_size_limit_exceeded":
return LimitExceededMessageWrapper.ITEM_SIZE_LIMIT_EXCEEDED;
case "element_size_limit_exceeded":
return LimitExceededMessageWrapper.ELEMENT_SIZE_LIMIT_EXCEEDED;
case "topicSubscriptionsLimitExceeded":
return LimitExceededMessageWrapper.topicSubscriptionsLimitExceeded;
case "operationsRateLimitExceeded":
return LimitExceededMessageWrapper.operationsRateLimitExceeded;
case "throughputRateLimitExceeded":
return LimitExceededMessageWrapper.throughputRateLimitExceeded;
case "requestSizeLimitExceeded":
return LimitExceededMessageWrapper.requestSizeLimitExceeded;
case "itemSizeLimitExceeded":
return LimitExceededMessageWrapper.itemSizeLimitExceeded;
case "elementSizeLimitExceeded":
return LimitExceededMessageWrapper.elementSizeLimitExceeded;
default:
return fromErrorString(message);
}
Expand All @@ -359,18 +359,18 @@ enum LimitExceededMessageWrapper {
static LimitExceededMessageWrapper fromErrorString(String errorString) {
String lowerCasedMessage = errorString.toLowerCase();
if (lowerCasedMessage.contains("subscribers")) {
return LimitExceededMessageWrapper.TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.topicSubscriptionsLimitExceeded;
} else if (lowerCasedMessage.contains("operations")) {
return LimitExceededMessageWrapper.OPERATIONS_RATE_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.operationsRateLimitExceeded;
} else if (lowerCasedMessage.contains("throughput")) {
return LimitExceededMessageWrapper.THROUGHPUT_RATE_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.throughputRateLimitExceeded;
} else if (lowerCasedMessage.contains("request limit")) {
return LimitExceededMessageWrapper.REQUEST_SIZE_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.requestSizeLimitExceeded;
} else if (lowerCasedMessage.contains("item size")) {
return LimitExceededMessageWrapper.ITEM_SIZE_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.itemSizeLimitExceeded;
} else if (lowerCasedMessage.contains("element size")) {
return LimitExceededMessageWrapper.ELEMENT_SIZE_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.elementSizeLimitExceeded;
}
return LimitExceededMessageWrapper.UNKNOWN_LIMIT_EXCEEDED;
return LimitExceededMessageWrapper.unknownLimitExceeded;
}
}
1 change: 1 addition & 0 deletions lib/src/internal/data_client.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:momento/generated/cacheclient.pbgrpc.dart';
import 'package:momento/generated/common.pb.dart';
import 'package:momento/momento.dart';
import 'package:momento/src/config/cache_configuration.dart';
import 'package:momento/src/errors/errors.dart';
Expand Down

0 comments on commit 7fe4527

Please sign in to comment.