This commit is contained in:
19
docs/snippets/php/api/error_handling.md
Normal file
19
docs/snippets/php/api/error_handling.md
Normal file
@@ -0,0 +1,19 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\ExtractionConfig;
|
||||
use Kreuzberg\KreuzbergException;
|
||||
|
||||
$config = new ExtractionConfig();
|
||||
try {
|
||||
$result = Kreuzberg::extractFileSync('document.pdf', null, $config);
|
||||
echo $result->getContent();
|
||||
} catch (KreuzbergException $e) {
|
||||
// The extension throws KreuzbergException with the error message
|
||||
// Error context is available in the exception message
|
||||
echo "Extraction failed: " . $e->getMessage() . "\n";
|
||||
echo "Error code: " . $e->getCode() . "\n";
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user