Module: Kreuzberg::ErrorContext
- Defined in:
- lib/kreuzberg/error_context.rb
Class Method Summary collapse
-
.classify_error(message) ⇒ Integer
Classify an error message into a Kreuzberg error code.
-
.error_code_description(code) ⇒ String
Get the description of an error code.
-
.error_code_name(code) ⇒ String
Get the human-readable name of an error code.
-
.error_details ⇒ Hash
Get detailed error information from the last operation.
-
.last_error_code ⇒ Integer
Error code constant (ERROR_CODE_* values), or 0 on success.
-
.last_panic_context ⇒ Errors::PanicContext?
Get panic context information from the last error.
-
.last_panic_context_json ⇒ String?
Get panic context as raw JSON string.
Class Method Details
.classify_error(message) ⇒ Integer
Classify an error message into a Kreuzberg error code.
Analyzes an error message and returns the most likely error code (0-7). Useful for converting third-party error messages into Kreuzberg categories.
Error code mapping:
-
0: Validation
-
1: Parsing
-
2: OCR
-
3: MissingDependency
-
4: IO
-
5: Plugin
-
6: UnsupportedFormat
-
7: Internal
101 102 103 104 105 |
# File 'lib/kreuzberg/error_context.rb', line 101 def classify_error() Kreuzberg._classify_error_native() rescue StandardError 7 end |
.error_code_description(code) ⇒ String
Get the description of an error code.
129 130 131 132 133 |
# File 'lib/kreuzberg/error_context.rb', line 129 def error_code_description(code) Kreuzberg._error_code_description_native(code) rescue StandardError 'Unknown error code' end |
.error_code_name(code) ⇒ String
Get the human-readable name of an error code.
115 116 117 118 119 |
# File 'lib/kreuzberg/error_context.rb', line 115 def error_code_name(code) Kreuzberg._error_code_name_native(code) rescue StandardError 'unknown' end |
.error_details ⇒ Hash
Get detailed error information from the last operation.
Returns comprehensive error details including message, code, type, source location, and panic information.
72 73 74 75 76 |
# File 'lib/kreuzberg/error_context.rb', line 72 def error_details Kreuzberg._get_error_details_native rescue StandardError {} end |
.last_error_code ⇒ Integer
Returns Error code constant (ERROR_CODE_* values), or 0 on success.
10 11 12 13 14 |
# File 'lib/kreuzberg/error_context.rb', line 10 def last_error_code Kreuzberg._last_error_code_native rescue StandardError 0 end |
.last_panic_context ⇒ Errors::PanicContext?
Get panic context information from the last error.
Returns a Kreuzberg::Errors::PanicContext object containing detailed information about the last panic that occurred in the Rust core. Includes file path, line number, function name, error message, and timestamp.
31 32 33 34 35 36 37 38 |
# File 'lib/kreuzberg/error_context.rb', line 31 def last_panic_context json_str = Kreuzberg._last_panic_context_json_native return nil unless json_str Errors::PanicContext.from_json(json_str) rescue StandardError nil end |
.last_panic_context_json ⇒ String?
Get panic context as raw JSON string.
Returns the panic context information as a JSON string for raw access or custom parsing. Returns nil if no panic has occurred.
53 54 55 56 57 |
# File 'lib/kreuzberg/error_context.rb', line 53 def last_panic_context_json Kreuzberg._last_panic_context_json_native rescue StandardError nil end |