Skip to content

Commit

Permalink
make sure to user lower case grpc error message when parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Nov 5, 2024
1 parent ca2a124 commit 016ac20
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Cache/Errors/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,18 @@ private function setMessageWrapper(string $message, ?array $metadata = null) {

// If `err` metadata is unavailable, try to use the error details field
// to set an appropriate error message.
if (str_contains($message, "subscribers")) {
$lowerCasedMessage = strtolower($message);
if (str_contains($lowerCasedMessage, "subscribers")) {
$this->messageWrapper = LimitExceededMessageWrapper::TOPIC_SUBSCRIPTIONS_LIMIT_EXCEEDED;
} elseif (str_contains($message, "operations")) {
} elseif (str_contains($lowerCasedMessage, "operations")) {
$this->messageWrapper = LimitExceededMessageWrapper::OPERATIONS_RATE_LIMIT_EXCEEDED;
} elseif (str_contains($message, "throughput")) {
} elseif (str_contains($lowerCasedMessage, "throughput")) {
$this->messageWrapper = LimitExceededMessageWrapper::THROUGHPUT_RATE_LIMIT_EXCEEDED;
} elseif (str_contains($message, "request limit")) {
} elseif (str_contains($lowerCasedMessage, "request limit")) {
$this->messageWrapper = LimitExceededMessageWrapper::REQUEST_SIZE_LIMIT_EXCEEDED;
} elseif (str_contains($message, "item size")) {
} elseif (str_contains($lowerCasedMessage, "item size")) {
$this->messageWrapper = LimitExceededMessageWrapper::ITEM_SIZE_LIMIT_EXCEEDED;
} elseif (str_contains($message, "element size")) {
} elseif (str_contains($lowerCasedMessage, "element size")) {
$this->messageWrapper = LimitExceededMessageWrapper::ELEMENT_SIZE_LIMIT_EXCEEDED;
} else {
// If all else fails, set a generic "limit exceeded" message
Expand Down

0 comments on commit 016ac20

Please sign in to comment.