Skip to content

Commit b568600

Browse files
feat!: rename errors to exceptions
1 parent 205ab97 commit b568600

24 files changed

+112
-112
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ However, builders are also provided `(new Dog)->withName("Joey")`.
6868

6969
### Handling errors
7070

71-
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Scrapegraphai\Errors\APIError` will be thrown:
71+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Scrapegraphai\Core\Exceptions\APIException` will be thrown:
7272

7373
```php
7474
<?php
7575

76-
use Scrapegraphai\Core\Errors\APIConnectionError;
76+
use Scrapegraphai\Core\Exceptions\APIConnectionException;
7777

7878
try {
7979
$completedSmartscraper = $client->smartscraper->create(
8080
userPrompt: "Extract the product name, price, and description"
8181
);
82-
} catch (APIConnectionError $e) {
82+
} catch (APIConnectionException $e) {
8383
echo "The server could not be reached", PHP_EOL;
8484
var_dump($e->getPrevious());
8585
} catch (RateLimitError $_) {
@@ -92,19 +92,19 @@ try {
9292

9393
Error codes are as follows:
9494

95-
| Cause | Error Type |
96-
| ---------------- | -------------------------- |
97-
| HTTP 400 | `BadRequestError` |
98-
| HTTP 401 | `AuthenticationError` |
99-
| HTTP 403 | `PermissionDeniedError` |
100-
| HTTP 404 | `NotFoundError` |
101-
| HTTP 409 | `ConflictError` |
102-
| HTTP 422 | `UnprocessableEntityError` |
103-
| HTTP 429 | `RateLimitError` |
104-
| HTTP >= 500 | `InternalServerError` |
105-
| Other HTTP error | `APIStatusError` |
106-
| Timeout | `APITimeoutError` |
107-
| Network error | `APIConnectionError` |
95+
| Cause | Error Type |
96+
| ---------------- | ------------------------------ |
97+
| HTTP 400 | `BadRequestException` |
98+
| HTTP 401 | `AuthenticationException` |
99+
| HTTP 403 | `PermissionDeniedException` |
100+
| HTTP 404 | `NotFoundException` |
101+
| HTTP 409 | `ConflictException` |
102+
| HTTP 422 | `UnprocessableEntityException` |
103+
| HTTP 429 | `RateLimitException` |
104+
| HTTP >= 500 | `InternalServerException` |
105+
| Other HTTP error | `APIStatusException` |
106+
| Timeout | `APITimeoutException` |
107+
| Network error | `APIConnectionException` |
108108

109109
### Retries
110110

src/Core/BaseClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Scrapegraphai\Core\Contracts\BaseStream;
1818
use Scrapegraphai\Core\Conversion\Contracts\Converter;
1919
use Scrapegraphai\Core\Conversion\Contracts\ConverterSource;
20-
use Scrapegraphai\Core\Errors\APIStatusError;
20+
use Scrapegraphai\Core\Exceptions\APIStatusException;
2121
use Scrapegraphai\RequestOptions;
2222

2323
/**
@@ -203,7 +203,7 @@ protected function sendRequest(
203203
}
204204

205205
if ($code >= 400 && $code < 500) {
206-
throw APIStatusError::from(request: $req, response: $rsp);
206+
throw APIStatusException::from(request: $req, response: $rsp);
207207
}
208208

209209
if ($code >= 500 && $retryCount < $opts->maxRetries) {

src/Core/Concerns/SdkPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Scrapegraphai\Client;
88
use Scrapegraphai\Core\Conversion\Contracts\Converter;
99
use Scrapegraphai\Core\Conversion\Contracts\ConverterSource;
10-
use Scrapegraphai\Core\Errors\APIStatusError;
10+
use Scrapegraphai\Core\Exceptions\APIStatusException;
1111
use Scrapegraphai\RequestOptions;
1212

1313
/**
@@ -52,7 +52,7 @@ public function hasNextPage(): bool
5252
*
5353
* @return static of static<Item>
5454
*
55-
* @throws APIStatusError
55+
* @throws APIStatusException
5656
*/
5757
public function getNextPage(): static
5858
{

src/Core/Errors/AuthenticationError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/BadRequestError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/ConflictError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/InternalServerError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/NotFoundError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/PermissionDeniedError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Core/Errors/RateLimitError.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)