File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Apisearch PHP Client.
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ *
9
+ * Feel free to edit as you please, and have fun.
10
+ *
11
+ * @author Marc Morera <[email protected] >
12
+ */
13
+
14
+ declare (strict_types=1 );
15
+
16
+ namespace Apisearch \Exception ;
17
+
18
+ /**
19
+ * Class TooManyRequestsException
20
+ */
21
+ class TooManyRequestsException extends TransportableException
22
+ {
23
+ /**
24
+ * Get http error code.
25
+ *
26
+ * @return int
27
+ */
28
+ public static function getTransportableHTTPError (): int
29
+ {
30
+ return 429 ;
31
+ }
32
+
33
+ /**
34
+ * Index exists.
35
+ *
36
+ * @return ResourceExistsException
37
+ */
38
+ public static function tooManyRequestsReached (): self
39
+ {
40
+ return new self ('You reached the rate limit. Please, check your permissions ' );
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ protected static function throwTransportableExceptionIfNeeded(
58
58
case ForbiddenException::getTransportableHTTPError ():
59
59
throw new ForbiddenException ($ response ['body ' ]['message ' ]);
60
60
case ConnectionException::getTransportableHTTPError ():
61
- throw new ConnectionException ('Apisearch returned an internal error code [500] ' );
61
+ throw new ConnectionException ('Apisearch returned an internal error code [500] - ' . $ response [ ' body ' ][ ' message ' ] );
62
62
}
63
63
}
64
64
}
You can’t perform that action at this time.
0 commit comments