diff --git a/src/Transport/ResultStatus.php b/src/Transport/ResultStatus.php index 130bc56a5..096ea2dd0 100644 --- a/src/Transport/ResultStatus.php +++ b/src/Transport/ResultStatus.php @@ -57,6 +57,15 @@ public static function success(): self return self::getInstance('SUCCESS'); } + /** + * Returns an instance of this enum representing the fact that the event + * failed to be sent because the content was too large. + */ + public static function contentTooLarge(): self + { + return self::getInstance('CONTENT_TOO_LARGE'); + } + /** * Returns an instance of this enum representing the fact that the event * failed to be sent because of API rate limiting. @@ -94,6 +103,8 @@ public static function createFromHttpStatusCode(int $statusCode): self switch (true) { case $statusCode >= 200 && $statusCode < 300: return self::success(); + case $statusCode === 413: + return self::contentTooLarge(); case $statusCode === 429: return self::rateLimit(); case $statusCode >= 400 && $statusCode < 500: diff --git a/tests/Transport/HttpTransportTest.php b/tests/Transport/HttpTransportTest.php index 206261eb0..7eb93cd3f 100644 --- a/tests/Transport/HttpTransportTest.php +++ b/tests/Transport/HttpTransportTest.php @@ -114,6 +114,18 @@ public static function sendDataProvider(): iterable ], ]; + yield [ + new Response(413, [], ''), + ResultStatus::contentTooLarge(), + false, + [ + 'info' => [ + 'Sending event [%s] to %s [project:%s].', + 'Sent event [%s] to %s [project:%s]. Result: "content_too_large" (status: 413).', + ], + ], + ]; + ClockMock::withClockMock(1644105600); yield [