This commit is contained in:
21
docs/snippets/ruby/api/error_handling.md
Normal file
21
docs/snippets/ruby/api/error_handling.md
Normal file
@@ -0,0 +1,21 @@
|
||||
```ruby title="Ruby"
|
||||
require 'kreuzberg'
|
||||
|
||||
begin
|
||||
result = Kreuzberg.extract_file_sync('missing.pdf')
|
||||
puts result.content
|
||||
rescue RuntimeError => e
|
||||
# All extraction errors are raised as RuntimeError
|
||||
# Check error message for specific error details
|
||||
case e.message
|
||||
when /validation/i
|
||||
puts "Validation error: #{e.message}"
|
||||
when /io|not found/i
|
||||
puts "IO error: #{e.message}"
|
||||
raise
|
||||
else
|
||||
puts "Extraction failed: #{e.message}"
|
||||
raise
|
||||
end
|
||||
end
|
||||
```
|
||||
Reference in New Issue
Block a user