Files
fil/docs/snippets/csharp/api/error_handling_extract.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

580 B

using Kreuzberg;

try
{
    var data = File.ReadAllBytes("document.unsupported");
    var result = KreuzbergLib.ExtractBytesSync(data, "application/x-custom", null);
    Console.WriteLine(result.Content);
}
catch (KreuzbergException ex) when (ex.Code == 1)
{
    Console.WriteLine("Validation error: Invalid MIME type");
}
catch (KreuzbergException ex) when (ex.Code == 2)
{
    Console.WriteLine("Format error: MIME type not supported");
}
catch (KreuzbergException ex)
{
    Console.WriteLine($"Extraction failed with error {ex.Code}: {ex.Message}");
}