Files
fil/docs/snippets/r/api/error_handling.md
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

27 lines
584 B
Markdown

```r title="R"
library(kreuzberg)
content <- charToRaw("Hello, world!")
result <- tryCatch(
{
json <- extract_bytes_sync(
content = content,
mime_type = "application/x-nonexistent",
config = ExtractionConfig$default()
)
jsonlite::fromJSON(json, simplifyVector = FALSE)
},
error = function(e) {
message(sprintf("Extraction failed: %s", conditionMessage(e)))
NULL
}
)
if (is.null(result)) {
cat("No content extracted; falling back to original bytes\n")
} else {
cat(sprintf("Extracted %d characters\n", nchar(result$content)))
}
```