1#[cfg(test)]
9mod tests;
10
11use std::fmt;
12use thiserror::Error as ThisError;
13
14#[derive(Debug, ThisError)]
115#[error("{message}")]
116pub struct InternalError {
117 pub(crate) class: ErrorClass,
118 pub(crate) origin: ErrorOrigin,
119 pub(crate) message: String,
120
121 pub(crate) detail: Option<ErrorDetail>,
124}
125
126impl InternalError {
127 #[cold]
131 #[inline(never)]
132 pub fn new(class: ErrorClass, origin: ErrorOrigin, message: impl Into<String>) -> Self {
133 let message = message.into();
134
135 let detail = match (class, origin) {
136 (ErrorClass::Corruption, ErrorOrigin::Store) => {
137 Some(ErrorDetail::Store(StoreError::Corrupt {
138 message: message.clone(),
139 }))
140 }
141 (ErrorClass::InvariantViolation, ErrorOrigin::Store) => {
142 Some(ErrorDetail::Store(StoreError::InvariantViolation {
143 message: message.clone(),
144 }))
145 }
146 _ => None,
147 };
148
149 Self {
150 class,
151 origin,
152 message,
153 detail,
154 }
155 }
156
157 #[must_use]
159 pub const fn class(&self) -> ErrorClass {
160 self.class
161 }
162
163 #[must_use]
165 pub const fn origin(&self) -> ErrorOrigin {
166 self.origin
167 }
168
169 #[must_use]
171 pub fn message(&self) -> &str {
172 &self.message
173 }
174
175 #[must_use]
177 pub const fn detail(&self) -> Option<&ErrorDetail> {
178 self.detail.as_ref()
179 }
180
181 #[must_use]
183 pub fn into_message(self) -> String {
184 self.message
185 }
186
187 #[cold]
189 #[inline(never)]
190 pub(crate) fn classified(
191 class: ErrorClass,
192 origin: ErrorOrigin,
193 message: impl Into<String>,
194 ) -> Self {
195 Self::new(class, origin, message)
196 }
197
198 #[cold]
200 #[inline(never)]
201 pub(crate) fn with_message(self, message: impl Into<String>) -> Self {
202 Self::classified(self.class, self.origin, message)
203 }
204
205 #[cold]
209 #[inline(never)]
210 pub(crate) fn with_origin(self, origin: ErrorOrigin) -> Self {
211 Self::classified(self.class, origin, self.message)
212 }
213
214 #[cold]
216 #[inline(never)]
217 pub(crate) fn index_invariant(message: impl Into<String>) -> Self {
218 Self::new(
219 ErrorClass::InvariantViolation,
220 ErrorOrigin::Index,
221 message.into(),
222 )
223 }
224
225 pub(crate) fn index_key_field_count_exceeds_max(
227 index_name: &str,
228 field_count: usize,
229 max_fields: usize,
230 ) -> Self {
231 Self::index_invariant(format!(
232 "index '{index_name}' has {field_count} fields (max {max_fields})",
233 ))
234 }
235
236 pub(crate) fn index_key_item_field_missing_on_entity_model(field: &str) -> Self {
238 Self::index_invariant(format!(
239 "index key item field missing on entity model: {field}",
240 ))
241 }
242
243 pub(crate) fn index_key_item_field_missing_on_lookup_row(field: &str) -> Self {
245 Self::index_invariant(format!(
246 "index key item field missing on lookup row: {field}",
247 ))
248 }
249
250 pub(crate) fn index_expression_source_type_mismatch(
252 index_name: &str,
253 expression: impl fmt::Display,
254 expected: &str,
255 source_label: &str,
256 ) -> Self {
257 Self::index_invariant(format!(
258 "index '{index_name}' expression '{expression}' expected {expected} source value, got {source_label}",
259 ))
260 }
261
262 #[cold]
265 #[inline(never)]
266 pub(crate) fn planner_executor_invariant(reason: impl Into<String>) -> Self {
267 Self::new(
268 ErrorClass::InvariantViolation,
269 ErrorOrigin::Planner,
270 Self::executor_invariant_message(reason),
271 )
272 }
273
274 #[cold]
277 #[inline(never)]
278 pub(crate) fn query_executor_invariant(reason: impl Into<String>) -> Self {
279 Self::new(
280 ErrorClass::InvariantViolation,
281 ErrorOrigin::Query,
282 Self::executor_invariant_message(reason),
283 )
284 }
285
286 #[cold]
289 #[inline(never)]
290 pub(crate) fn cursor_executor_invariant(reason: impl Into<String>) -> Self {
291 Self::new(
292 ErrorClass::InvariantViolation,
293 ErrorOrigin::Cursor,
294 Self::executor_invariant_message(reason),
295 )
296 }
297
298 #[cold]
300 #[inline(never)]
301 pub(crate) fn executor_invariant(message: impl Into<String>) -> Self {
302 Self::new(
303 ErrorClass::InvariantViolation,
304 ErrorOrigin::Executor,
305 message.into(),
306 )
307 }
308
309 #[cold]
311 #[inline(never)]
312 pub(crate) fn executor_internal(message: impl Into<String>) -> Self {
313 Self::new(ErrorClass::Internal, ErrorOrigin::Executor, message.into())
314 }
315
316 #[cold]
318 #[inline(never)]
319 pub(crate) fn executor_unsupported(message: impl Into<String>) -> Self {
320 Self::new(
321 ErrorClass::Unsupported,
322 ErrorOrigin::Executor,
323 message.into(),
324 )
325 }
326
327 pub(crate) fn mutation_entity_primary_key_missing(entity_path: &str, field_name: &str) -> Self {
329 Self::executor_invariant(format!(
330 "entity primary key field missing: {entity_path} field={field_name}",
331 ))
332 }
333
334 pub(crate) fn mutation_entity_primary_key_invalid_value(
336 entity_path: &str,
337 field_name: &str,
338 value: &crate::value::Value,
339 ) -> Self {
340 Self::executor_invariant(format!(
341 "entity primary key field has invalid value: {entity_path} field={field_name} value={value:?}",
342 ))
343 }
344
345 pub(crate) fn mutation_entity_primary_key_type_mismatch(
347 entity_path: &str,
348 field_name: &str,
349 value: &crate::value::Value,
350 ) -> Self {
351 Self::executor_invariant(format!(
352 "entity primary key field type mismatch: {entity_path} field={field_name} value={value:?}",
353 ))
354 }
355
356 pub(crate) fn mutation_entity_primary_key_mismatch(
358 entity_path: &str,
359 field_name: &str,
360 field_value: &crate::value::Value,
361 identity_key: &crate::value::Value,
362 ) -> Self {
363 Self::executor_invariant(format!(
364 "entity primary key mismatch: {entity_path} field={field_name} field_value={field_value:?} id_key={identity_key:?}",
365 ))
366 }
367
368 pub(crate) fn mutation_entity_field_missing(
370 entity_path: &str,
371 field_name: &str,
372 indexed: bool,
373 ) -> Self {
374 let indexed_note = if indexed { " (indexed)" } else { "" };
375
376 Self::executor_invariant(format!(
377 "entity field missing: {entity_path} field={field_name}{indexed_note}",
378 ))
379 }
380
381 pub(crate) fn mutation_entity_field_type_mismatch(
383 entity_path: &str,
384 field_name: &str,
385 value: &crate::value::Value,
386 ) -> Self {
387 Self::executor_invariant(format!(
388 "entity field type mismatch: {entity_path} field={field_name} value={value:?}",
389 ))
390 }
391
392 pub(crate) fn mutation_generated_field_explicit(entity_path: &str, field_name: &str) -> Self {
394 Self::executor_unsupported(format!(
395 "generated field may not be explicitly written: {entity_path} field={field_name}",
396 ))
397 }
398
399 pub(crate) fn mutation_create_missing_authored_fields(
401 entity_path: &str,
402 field_names: &str,
403 ) -> Self {
404 Self::executor_unsupported(format!(
405 "create requires explicit values for authorable fields {field_names}: {entity_path}",
406 ))
407 }
408
409 pub(crate) fn mutation_structural_after_image_invalid(
414 entity_path: &str,
415 data_key: impl fmt::Display,
416 detail: impl AsRef<str>,
417 ) -> Self {
418 Self::executor_invariant(format!(
419 "mutation result is invalid: {entity_path} key={data_key} ({})",
420 detail.as_ref(),
421 ))
422 }
423
424 pub(crate) fn mutation_structural_field_unknown(entity_path: &str, field_name: &str) -> Self {
426 Self::executor_invariant(format!(
427 "mutation field not found: {entity_path} field={field_name}",
428 ))
429 }
430
431 pub(crate) fn mutation_decimal_scale_mismatch(
433 entity_path: &str,
434 field_name: &str,
435 expected_scale: impl fmt::Display,
436 actual_scale: impl fmt::Display,
437 ) -> Self {
438 Self::executor_unsupported(format!(
439 "decimal field scale mismatch: {entity_path} field={field_name} expected_scale={expected_scale} actual_scale={actual_scale}",
440 ))
441 }
442
443 pub(crate) fn mutation_set_field_list_required(entity_path: &str, field_name: &str) -> Self {
445 Self::executor_invariant(format!(
446 "set field must encode as Value::List: {entity_path} field={field_name}",
447 ))
448 }
449
450 pub(crate) fn mutation_set_field_not_canonical(entity_path: &str, field_name: &str) -> Self {
452 Self::executor_invariant(format!(
453 "set field must be strictly ordered and deduplicated: {entity_path} field={field_name}",
454 ))
455 }
456
457 pub(crate) fn mutation_map_field_map_required(entity_path: &str, field_name: &str) -> Self {
459 Self::executor_invariant(format!(
460 "map field must encode as Value::Map: {entity_path} field={field_name}",
461 ))
462 }
463
464 pub(crate) fn mutation_map_field_entries_invalid(
466 entity_path: &str,
467 field_name: &str,
468 detail: impl fmt::Display,
469 ) -> Self {
470 Self::executor_invariant(format!(
471 "map field entries violate map invariants: {entity_path} field={field_name} ({detail})",
472 ))
473 }
474
475 pub(crate) fn mutation_map_field_entries_not_canonical(
477 entity_path: &str,
478 field_name: &str,
479 ) -> Self {
480 Self::executor_invariant(format!(
481 "map field entries are not in canonical deterministic order: {entity_path} field={field_name}",
482 ))
483 }
484
485 pub(crate) fn scalar_page_ordering_after_filtering_required() -> Self {
487 Self::query_executor_invariant("ordering must run after filtering")
488 }
489
490 pub(crate) fn scalar_page_cursor_boundary_order_required() -> Self {
492 Self::query_executor_invariant("cursor boundary requires ordering")
493 }
494
495 pub(crate) fn scalar_page_cursor_boundary_after_ordering_required() -> Self {
497 Self::query_executor_invariant("cursor boundary must run after ordering")
498 }
499
500 pub(crate) fn scalar_page_pagination_after_ordering_required() -> Self {
502 Self::query_executor_invariant("pagination must run after ordering")
503 }
504
505 pub(crate) fn scalar_page_delete_limit_after_ordering_required() -> Self {
507 Self::query_executor_invariant("delete limit must run after ordering")
508 }
509
510 pub(crate) fn load_runtime_scalar_payload_required() -> Self {
512 Self::query_executor_invariant("scalar load mode must carry scalar runtime payload")
513 }
514
515 pub(crate) fn load_runtime_grouped_payload_required() -> Self {
517 Self::query_executor_invariant("grouped load mode must carry grouped runtime payload")
518 }
519
520 pub(crate) fn load_runtime_scalar_surface_payload_required() -> Self {
522 Self::query_executor_invariant("scalar page load mode must carry scalar runtime payload")
523 }
524
525 pub(crate) fn load_runtime_grouped_surface_payload_required() -> Self {
527 Self::query_executor_invariant("grouped page load mode must carry grouped runtime payload")
528 }
529
530 pub(crate) fn load_executor_load_plan_required() -> Self {
532 Self::query_executor_invariant("load executor requires load plans")
533 }
534
535 pub(crate) fn delete_executor_grouped_unsupported() -> Self {
537 Self::executor_unsupported("grouped query execution is not yet enabled in this release")
538 }
539
540 pub(crate) fn delete_executor_delete_plan_required() -> Self {
542 Self::query_executor_invariant("delete executor requires delete plans")
543 }
544
545 pub(crate) fn aggregate_fold_mode_terminal_contract_required() -> Self {
547 Self::query_executor_invariant(
548 "aggregate fold mode must match route fold-mode contract for aggregate terminal",
549 )
550 }
551
552 pub(crate) fn fast_stream_exact_key_count_required() -> Self {
554 Self::query_executor_invariant("fast-path stream must expose an exact key-count hint")
555 }
556
557 pub(crate) fn fast_stream_route_kind_request_match_required() -> Self {
559 Self::query_executor_invariant("fast-stream route kind/request mismatch")
560 }
561
562 pub(crate) fn secondary_index_prefix_spec_required() -> Self {
564 Self::query_executor_invariant(
565 "index-prefix executable spec must be materialized for index-prefix plans",
566 )
567 }
568
569 pub(crate) fn index_range_limit_spec_required() -> Self {
571 Self::query_executor_invariant(
572 "index-range executable spec must be materialized for index-range plans",
573 )
574 }
575
576 pub(crate) fn mutation_atomic_save_duplicate_key(
578 entity_path: &str,
579 key: impl fmt::Display,
580 ) -> Self {
581 Self::executor_unsupported(format!(
582 "atomic save batch rejected duplicate key: entity={entity_path} key={key}",
583 ))
584 }
585
586 pub(crate) fn mutation_index_store_generation_changed(
588 expected_generation: u64,
589 observed_generation: u64,
590 ) -> Self {
591 Self::executor_invariant(format!(
592 "index store generation changed between preflight and apply: expected {expected_generation}, found {observed_generation}",
593 ))
594 }
595
596 #[must_use]
598 #[cold]
599 #[inline(never)]
600 pub(crate) fn executor_invariant_message(reason: impl Into<String>) -> String {
601 format!("executor invariant violated: {}", reason.into())
602 }
603
604 #[cold]
606 #[inline(never)]
607 pub(crate) fn planner_invariant(message: impl Into<String>) -> Self {
608 Self::new(
609 ErrorClass::InvariantViolation,
610 ErrorOrigin::Planner,
611 message.into(),
612 )
613 }
614
615 #[must_use]
617 pub(crate) fn invalid_logical_plan_message(reason: impl Into<String>) -> String {
618 format!("invalid logical plan: {}", reason.into())
619 }
620
621 pub(crate) fn query_invalid_logical_plan(reason: impl Into<String>) -> Self {
623 Self::planner_invariant(Self::invalid_logical_plan_message(reason))
624 }
625
626 #[cold]
628 #[inline(never)]
629 pub(crate) fn query_invariant(message: impl Into<String>) -> Self {
630 Self::new(
631 ErrorClass::InvariantViolation,
632 ErrorOrigin::Query,
633 message.into(),
634 )
635 }
636
637 pub(crate) fn store_invariant(message: impl Into<String>) -> Self {
639 Self::new(
640 ErrorClass::InvariantViolation,
641 ErrorOrigin::Store,
642 message.into(),
643 )
644 }
645
646 pub(crate) fn duplicate_runtime_hooks_for_entity_tag(
648 entity_tag: crate::types::EntityTag,
649 ) -> Self {
650 Self::store_invariant(format!(
651 "duplicate runtime hooks for entity tag '{}'",
652 entity_tag.value()
653 ))
654 }
655
656 pub(crate) fn duplicate_runtime_hooks_for_entity_path(entity_path: &str) -> Self {
658 Self::store_invariant(format!(
659 "duplicate runtime hooks for entity path '{entity_path}'"
660 ))
661 }
662
663 #[cold]
665 #[inline(never)]
666 pub(crate) fn store_internal(message: impl Into<String>) -> Self {
667 Self::new(ErrorClass::Internal, ErrorOrigin::Store, message.into())
668 }
669
670 pub(crate) fn commit_memory_id_unconfigured() -> Self {
672 Self::store_internal(
673 "commit memory id is not configured; initialize recovery before commit store access",
674 )
675 }
676
677 pub(crate) fn commit_memory_id_mismatch(cached_id: u8, configured_id: u8) -> Self {
679 Self::store_internal(format!(
680 "commit memory id mismatch: cached={cached_id}, configured={configured_id}",
681 ))
682 }
683
684 pub(crate) fn delete_rollback_row_required() -> Self {
686 Self::store_internal("missing raw row for delete rollback")
687 }
688
689 pub(crate) fn commit_memory_registry_init_failed(err: impl fmt::Display) -> Self {
691 Self::store_internal(format!("memory registry init failed: {err}"))
692 }
693
694 pub(crate) fn migration_next_step_index_u64_required(id: &str, version: u64) -> Self {
696 Self::store_internal(format!(
697 "migration '{id}@{version}' next step index does not fit persisted u64 cursor",
698 ))
699 }
700
701 pub(crate) fn recovery_integrity_validation_failed(
703 missing_index_entries: u64,
704 divergent_index_entries: u64,
705 orphan_index_references: u64,
706 ) -> Self {
707 Self::store_corruption(format!(
708 "recovery integrity validation failed: missing_index_entries={missing_index_entries} divergent_index_entries={divergent_index_entries} orphan_index_references={orphan_index_references}",
709 ))
710 }
711
712 #[cold]
714 #[inline(never)]
715 pub(crate) fn index_internal(message: impl Into<String>) -> Self {
716 Self::new(ErrorClass::Internal, ErrorOrigin::Index, message.into())
717 }
718
719 pub(crate) fn structural_index_removal_entity_key_required() -> Self {
721 Self::index_internal("missing old entity key for structural index removal")
722 }
723
724 pub(crate) fn structural_index_insertion_entity_key_required() -> Self {
726 Self::index_internal("missing new entity key for structural index insertion")
727 }
728
729 pub(crate) fn index_commit_op_old_entity_key_required() -> Self {
731 Self::index_internal("missing old entity key for index removal")
732 }
733
734 pub(crate) fn index_commit_op_new_entity_key_required() -> Self {
736 Self::index_internal("missing new entity key for index insertion")
737 }
738
739 #[cfg(test)]
741 pub(crate) fn query_internal(message: impl Into<String>) -> Self {
742 Self::new(ErrorClass::Internal, ErrorOrigin::Query, message.into())
743 }
744
745 #[cold]
747 #[inline(never)]
748 pub(crate) fn query_unsupported(message: impl Into<String>) -> Self {
749 Self::new(ErrorClass::Unsupported, ErrorOrigin::Query, message.into())
750 }
751
752 #[cold]
754 #[inline(never)]
755 pub(crate) fn serialize_internal(message: impl Into<String>) -> Self {
756 Self::new(ErrorClass::Internal, ErrorOrigin::Serialize, message.into())
757 }
758
759 pub(crate) fn persisted_row_encode_failed(detail: impl fmt::Display) -> Self {
761 Self::serialize_internal(format!("row encode failed: {detail}"))
762 }
763
764 pub(crate) fn persisted_row_field_encode_failed(
766 field_name: &str,
767 detail: impl fmt::Display,
768 ) -> Self {
769 Self::serialize_internal(format!(
770 "row encode failed for field '{field_name}': {detail}",
771 ))
772 }
773
774 pub(crate) fn bytes_field_value_encode_failed(detail: impl fmt::Display) -> Self {
776 Self::serialize_internal(format!("bytes(field) value encode failed: {detail}"))
777 }
778
779 pub(crate) fn migration_state_serialize_failed(err: impl fmt::Display) -> Self {
781 Self::serialize_internal(format!("failed to serialize migration state: {err}"))
782 }
783
784 #[cold]
786 #[inline(never)]
787 pub(crate) fn store_corruption(message: impl Into<String>) -> Self {
788 Self::new(ErrorClass::Corruption, ErrorOrigin::Store, message.into())
789 }
790
791 pub(crate) fn multiple_commit_memory_ids_registered(ids: impl fmt::Debug) -> Self {
793 Self::store_corruption(format!(
794 "multiple commit marker memory ids registered: {ids:?}"
795 ))
796 }
797
798 pub(crate) fn migration_persisted_step_index_invalid_usize(
800 id: &str,
801 version: u64,
802 step_index: u64,
803 ) -> Self {
804 Self::store_corruption(format!(
805 "migration '{id}@{version}' persisted step index does not fit runtime usize: {step_index}",
806 ))
807 }
808
809 pub(crate) fn migration_persisted_step_index_out_of_bounds(
811 id: &str,
812 version: u64,
813 step_index: usize,
814 total_steps: usize,
815 ) -> Self {
816 Self::store_corruption(format!(
817 "migration '{id}@{version}' persisted step index out of bounds: {step_index} > {total_steps}",
818 ))
819 }
820
821 pub(crate) fn commit_corruption(detail: impl fmt::Display) -> Self {
823 Self::store_corruption(format!("commit marker corrupted: {detail}"))
824 }
825
826 pub(crate) fn commit_component_corruption(component: &str, detail: impl fmt::Display) -> Self {
828 Self::store_corruption(format!("commit marker {component} corrupted: {detail}"))
829 }
830
831 pub(crate) fn commit_id_generation_failed(detail: impl fmt::Display) -> Self {
833 Self::store_internal(format!("commit id generation failed: {detail}"))
834 }
835
836 pub(crate) fn commit_marker_payload_exceeds_u32_length_limit(label: &str, len: usize) -> Self {
838 Self::store_unsupported(format!("{label} exceeds u32 length limit: {len} bytes"))
839 }
840
841 pub(crate) fn commit_component_length_invalid(
843 component: &str,
844 len: usize,
845 expected: impl fmt::Display,
846 ) -> Self {
847 Self::commit_component_corruption(
848 component,
849 format!("invalid length {len}, expected {expected}"),
850 )
851 }
852
853 pub(crate) fn commit_marker_exceeds_max_size(size: usize, max_size: u32) -> Self {
855 Self::commit_corruption(format!(
856 "commit marker exceeds max size: {size} bytes (limit {max_size})",
857 ))
858 }
859
860 #[cfg(test)]
862 pub(crate) fn commit_marker_exceeds_max_size_before_persist(
863 size: usize,
864 max_size: u32,
865 ) -> Self {
866 Self::store_unsupported(format!(
867 "commit marker exceeds max size: {size} bytes (limit {max_size})",
868 ))
869 }
870
871 pub(crate) fn commit_control_slot_exceeds_max_size(size: usize, max_size: u32) -> Self {
873 Self::store_unsupported(format!(
874 "commit control slot exceeds max size: {size} bytes (limit {max_size})",
875 ))
876 }
877
878 pub(crate) fn commit_control_slot_marker_bytes_exceed_u32_length_limit(size: usize) -> Self {
880 Self::store_unsupported(format!(
881 "commit marker bytes exceed u32 length limit: {size} bytes",
882 ))
883 }
884
885 pub(crate) fn commit_control_slot_migration_bytes_exceed_u32_length_limit(size: usize) -> Self {
887 Self::store_unsupported(format!(
888 "commit migration bytes exceed u32 length limit: {size} bytes",
889 ))
890 }
891
892 pub(crate) fn startup_index_rebuild_invalid_data_key(
894 store_path: &str,
895 detail: impl fmt::Display,
896 ) -> Self {
897 Self::store_corruption(format!(
898 "startup index rebuild failed: invalid data key in store '{store_path}' ({detail})",
899 ))
900 }
901
902 #[cold]
904 #[inline(never)]
905 pub(crate) fn index_corruption(message: impl Into<String>) -> Self {
906 Self::new(ErrorClass::Corruption, ErrorOrigin::Index, message.into())
907 }
908
909 pub(crate) fn index_unique_validation_corruption(
911 entity_path: &str,
912 fields: &str,
913 detail: impl fmt::Display,
914 ) -> Self {
915 Self::index_plan_index_corruption(format!(
916 "index corrupted: {entity_path} ({fields}) -> {detail}",
917 ))
918 }
919
920 pub(crate) fn structural_index_entry_corruption(
922 entity_path: &str,
923 fields: &str,
924 detail: impl fmt::Display,
925 ) -> Self {
926 Self::index_plan_index_corruption(format!(
927 "index corrupted: {entity_path} ({fields}) -> {detail}",
928 ))
929 }
930
931 pub(crate) fn index_unique_validation_entity_key_required() -> Self {
933 Self::index_invariant("missing entity key during unique validation")
934 }
935
936 pub(crate) fn index_unique_validation_row_deserialize_failed(
938 data_key: impl fmt::Display,
939 source: impl fmt::Display,
940 ) -> Self {
941 Self::index_plan_serialize_corruption(format!(
942 "failed to structurally deserialize row: {data_key} ({source})"
943 ))
944 }
945
946 pub(crate) fn index_unique_validation_primary_key_decode_failed(
948 data_key: impl fmt::Display,
949 source: impl fmt::Display,
950 ) -> Self {
951 Self::index_plan_serialize_corruption(format!(
952 "failed to decode structural primary-key slot: {data_key} ({source})"
953 ))
954 }
955
956 pub(crate) fn index_unique_validation_key_rebuild_failed(
958 data_key: impl fmt::Display,
959 entity_path: &str,
960 source: impl fmt::Display,
961 ) -> Self {
962 Self::index_plan_serialize_corruption(format!(
963 "failed to structurally decode unique key row {data_key} for {entity_path}: {source}",
964 ))
965 }
966
967 pub(crate) fn index_unique_validation_row_required(data_key: impl fmt::Display) -> Self {
969 Self::index_plan_store_corruption(format!("missing row: {data_key}"))
970 }
971
972 pub(crate) fn index_only_predicate_component_required() -> Self {
974 Self::index_invariant("index-only predicate program referenced missing index component")
975 }
976
977 pub(crate) fn index_scan_continuation_anchor_within_envelope_required() -> Self {
979 Self::index_invariant(
980 "index-range continuation anchor is outside the requested range envelope",
981 )
982 }
983
984 pub(crate) fn index_scan_continuation_advancement_required() -> Self {
986 Self::index_invariant("index-range continuation scan did not advance beyond the anchor")
987 }
988
989 pub(crate) fn index_scan_key_corrupted_during(
991 context: &'static str,
992 err: impl fmt::Display,
993 ) -> Self {
994 Self::index_corruption(format!("index key corrupted during {context}: {err}"))
995 }
996
997 pub(crate) fn index_projection_component_required(
999 index_name: &str,
1000 component_index: usize,
1001 ) -> Self {
1002 Self::index_invariant(format!(
1003 "index projection referenced missing component: index='{index_name}' component_index={component_index}",
1004 ))
1005 }
1006
1007 pub(crate) fn unique_index_entry_single_key_required() -> Self {
1009 Self::index_corruption("unique index entry contains an unexpected number of keys")
1010 }
1011
1012 pub(crate) fn index_entry_decode_failed(err: impl fmt::Display) -> Self {
1014 Self::index_corruption(err.to_string())
1015 }
1016
1017 pub(crate) fn serialize_corruption(message: impl Into<String>) -> Self {
1019 Self::new(
1020 ErrorClass::Corruption,
1021 ErrorOrigin::Serialize,
1022 message.into(),
1023 )
1024 }
1025
1026 pub(crate) fn persisted_row_decode_failed(detail: impl fmt::Display) -> Self {
1028 Self::serialize_corruption(format!("row decode: {detail}"))
1029 }
1030
1031 pub(crate) fn persisted_row_field_decode_failed(
1033 field_name: &str,
1034 detail: impl fmt::Display,
1035 ) -> Self {
1036 Self::serialize_corruption(format!(
1037 "row decode failed for field '{field_name}': {detail}",
1038 ))
1039 }
1040
1041 pub(crate) fn persisted_row_field_kind_decode_failed(
1043 field_name: &str,
1044 field_kind: impl fmt::Debug,
1045 detail: impl fmt::Display,
1046 ) -> Self {
1047 Self::persisted_row_field_decode_failed(
1048 field_name,
1049 format!("kind={field_kind:?}: {detail}"),
1050 )
1051 }
1052
1053 pub(crate) fn persisted_row_field_payload_exact_len_required(
1055 field_name: &str,
1056 payload_kind: &str,
1057 expected_len: usize,
1058 ) -> Self {
1059 let unit = if expected_len == 1 { "byte" } else { "bytes" };
1060
1061 Self::persisted_row_field_decode_failed(
1062 field_name,
1063 format!("{payload_kind} payload must be exactly {expected_len} {unit}"),
1064 )
1065 }
1066
1067 pub(crate) fn persisted_row_field_payload_must_be_empty(
1069 field_name: &str,
1070 payload_kind: &str,
1071 ) -> Self {
1072 Self::persisted_row_field_decode_failed(
1073 field_name,
1074 format!("{payload_kind} payload must be empty"),
1075 )
1076 }
1077
1078 pub(crate) fn persisted_row_field_payload_invalid_byte(
1080 field_name: &str,
1081 payload_kind: &str,
1082 value: u8,
1083 ) -> Self {
1084 Self::persisted_row_field_decode_failed(
1085 field_name,
1086 format!("invalid {payload_kind} payload byte {value}"),
1087 )
1088 }
1089
1090 pub(crate) fn persisted_row_field_payload_non_finite(
1092 field_name: &str,
1093 payload_kind: &str,
1094 ) -> Self {
1095 Self::persisted_row_field_decode_failed(
1096 field_name,
1097 format!("{payload_kind} payload is non-finite"),
1098 )
1099 }
1100
1101 pub(crate) fn persisted_row_field_payload_out_of_range(
1103 field_name: &str,
1104 payload_kind: &str,
1105 ) -> Self {
1106 Self::persisted_row_field_decode_failed(
1107 field_name,
1108 format!("{payload_kind} payload out of range for target type"),
1109 )
1110 }
1111
1112 pub(crate) fn persisted_row_field_text_payload_invalid_utf8(
1114 field_name: &str,
1115 detail: impl fmt::Display,
1116 ) -> Self {
1117 Self::persisted_row_field_decode_failed(
1118 field_name,
1119 format!("invalid UTF-8 text payload ({detail})"),
1120 )
1121 }
1122
1123 pub(crate) fn persisted_row_slot_lookup_out_of_bounds(model_path: &str, slot: usize) -> Self {
1125 Self::index_invariant(format!(
1126 "slot lookup outside model bounds during structural row access: model='{model_path}' slot={slot}",
1127 ))
1128 }
1129
1130 pub(crate) fn persisted_row_slot_cache_lookup_out_of_bounds(
1132 model_path: &str,
1133 slot: usize,
1134 ) -> Self {
1135 Self::index_invariant(format!(
1136 "slot cache lookup outside model bounds during structural row access: model='{model_path}' slot={slot}",
1137 ))
1138 }
1139
1140 pub(crate) fn persisted_row_primary_key_not_storage_encodable(
1142 data_key: impl fmt::Debug,
1143 detail: impl fmt::Display,
1144 ) -> Self {
1145 Self::persisted_row_decode_failed(format!(
1146 "primary-key value is not storage-key encodable: {data_key:?} ({detail})",
1147 ))
1148 }
1149
1150 pub(crate) fn persisted_row_primary_key_slot_missing(data_key: impl fmt::Debug) -> Self {
1152 Self::persisted_row_decode_failed(format!(
1153 "missing primary-key slot while validating {data_key:?}",
1154 ))
1155 }
1156
1157 pub(crate) fn persisted_row_key_mismatch(
1159 expected_key: impl fmt::Debug,
1160 found_key: impl fmt::Debug,
1161 ) -> Self {
1162 Self::store_corruption(format!(
1163 "row key mismatch: expected {expected_key:?}, found {found_key:?}",
1164 ))
1165 }
1166
1167 pub(crate) fn persisted_row_declared_field_missing(field_name: &str) -> Self {
1169 Self::persisted_row_decode_failed(format!("missing declared field `{field_name}`"))
1170 }
1171
1172 pub(crate) fn data_key_entity_mismatch(
1174 expected: impl fmt::Display,
1175 found: impl fmt::Display,
1176 ) -> Self {
1177 Self::store_corruption(format!(
1178 "data key entity mismatch: expected {expected}, found {found}",
1179 ))
1180 }
1181
1182 pub(crate) fn data_key_primary_key_decode_failed(value: impl fmt::Debug) -> Self {
1184 Self::store_corruption(format!("data key primary key decode failed: {value:?}"))
1185 }
1186
1187 pub(crate) fn reverse_index_ordinal_overflow(
1189 source_path: &str,
1190 field_name: &str,
1191 target_path: &str,
1192 detail: impl fmt::Display,
1193 ) -> Self {
1194 Self::index_internal(format!(
1195 "reverse index ordinal overflow: source={source_path} field={field_name} target={target_path} ({detail})",
1196 ))
1197 }
1198
1199 pub(crate) fn reverse_index_entry_corrupted(
1201 source_path: &str,
1202 field_name: &str,
1203 target_path: &str,
1204 index_key: impl fmt::Debug,
1205 detail: impl fmt::Display,
1206 ) -> Self {
1207 Self::index_corruption(format!(
1208 "reverse index entry corrupted: source={source_path} field={field_name} target={target_path} key={index_key:?} ({detail})",
1209 ))
1210 }
1211
1212 pub(crate) fn reverse_index_entry_encode_failed(
1214 source_path: &str,
1215 field_name: &str,
1216 target_path: &str,
1217 detail: impl fmt::Display,
1218 ) -> Self {
1219 Self::index_unsupported(format!(
1220 "reverse index entry encoding failed: source={source_path} field={field_name} target={target_path} ({detail})",
1221 ))
1222 }
1223
1224 pub(crate) fn relation_target_store_missing(
1226 source_path: &str,
1227 field_name: &str,
1228 target_path: &str,
1229 store_path: &str,
1230 detail: impl fmt::Display,
1231 ) -> Self {
1232 Self::executor_internal(format!(
1233 "relation target store missing: source={source_path} field={field_name} target={target_path} store={store_path} ({detail})",
1234 ))
1235 }
1236
1237 pub(crate) fn relation_target_key_decode_failed(
1239 context_label: &str,
1240 source_path: &str,
1241 field_name: &str,
1242 target_path: &str,
1243 detail: impl fmt::Display,
1244 ) -> Self {
1245 Self::identity_corruption(format!(
1246 "{context_label}: source={source_path} field={field_name} target={target_path} ({detail})",
1247 ))
1248 }
1249
1250 pub(crate) fn relation_target_entity_mismatch(
1252 context_label: &str,
1253 source_path: &str,
1254 field_name: &str,
1255 target_path: &str,
1256 target_entity_name: &str,
1257 expected_tag: impl fmt::Display,
1258 actual_tag: impl fmt::Display,
1259 ) -> Self {
1260 Self::store_corruption(format!(
1261 "{context_label}: source={source_path} field={field_name} target={target_path} expected={target_entity_name} (tag={expected_tag}) actual_tag={actual_tag}",
1262 ))
1263 }
1264
1265 pub(crate) fn relation_source_row_decode_failed(
1267 source_path: &str,
1268 field_name: &str,
1269 target_path: &str,
1270 detail: impl fmt::Display,
1271 ) -> Self {
1272 Self::serialize_corruption(format!(
1273 "relation source row decode: source={source_path} field={field_name} target={target_path} ({detail})",
1274 ))
1275 }
1276
1277 pub(crate) fn relation_source_row_unsupported_scalar_relation_key(
1279 source_path: &str,
1280 field_name: &str,
1281 target_path: &str,
1282 ) -> Self {
1283 Self::serialize_corruption(format!(
1284 "relation source row decode: unsupported scalar relation key: source={source_path} field={field_name} target={target_path}",
1285 ))
1286 }
1287
1288 pub(crate) fn relation_source_row_invalid_field_kind(field_kind: impl fmt::Debug) -> Self {
1290 Self::serialize_corruption(format!(
1291 "invalid strong relation field kind during structural decode: {field_kind:?}"
1292 ))
1293 }
1294
1295 pub(crate) fn relation_source_row_unsupported_key_kind(field_kind: impl fmt::Debug) -> Self {
1297 Self::serialize_corruption(format!(
1298 "unsupported strong relation key kind during structural decode: {field_kind:?}"
1299 ))
1300 }
1301
1302 pub(crate) fn reverse_index_relation_target_decode_invariant_violated(
1304 source_path: &str,
1305 field_name: &str,
1306 target_path: &str,
1307 ) -> Self {
1308 Self::executor_internal(format!(
1309 "relation target decode invariant violated while preparing reverse index: source={source_path} field={field_name} target={target_path}",
1310 ))
1311 }
1312
1313 pub(crate) fn bytes_covering_component_payload_empty() -> Self {
1315 Self::index_corruption("index component payload is empty during covering projection decode")
1316 }
1317
1318 pub(crate) fn bytes_covering_bool_payload_truncated() -> Self {
1320 Self::index_corruption("bool covering component payload is truncated")
1321 }
1322
1323 pub(crate) fn bytes_covering_component_payload_invalid_length(payload_kind: &str) -> Self {
1325 Self::index_corruption(format!(
1326 "{payload_kind} covering component payload has invalid length"
1327 ))
1328 }
1329
1330 pub(crate) fn bytes_covering_bool_payload_invalid_value() -> Self {
1332 Self::index_corruption("bool covering component payload has invalid value")
1333 }
1334
1335 pub(crate) fn bytes_covering_text_payload_invalid_terminator() -> Self {
1337 Self::index_corruption("text covering component payload has invalid terminator")
1338 }
1339
1340 pub(crate) fn bytes_covering_text_payload_trailing_bytes() -> Self {
1342 Self::index_corruption("text covering component payload contains trailing bytes")
1343 }
1344
1345 pub(crate) fn bytes_covering_text_payload_invalid_utf8() -> Self {
1347 Self::index_corruption("text covering component payload is not valid UTF-8")
1348 }
1349
1350 pub(crate) fn bytes_covering_text_payload_invalid_escape_byte() -> Self {
1352 Self::index_corruption("text covering component payload has invalid escape byte")
1353 }
1354
1355 pub(crate) fn bytes_covering_text_payload_missing_terminator() -> Self {
1357 Self::index_corruption("text covering component payload is missing terminator")
1358 }
1359
1360 #[must_use]
1362 pub fn missing_persisted_slot(field_name: &'static str) -> Self {
1363 Self::serialize_corruption(format!("row decode: missing required field '{field_name}'"))
1364 }
1365
1366 pub(crate) fn identity_corruption(message: impl Into<String>) -> Self {
1368 Self::new(
1369 ErrorClass::Corruption,
1370 ErrorOrigin::Identity,
1371 message.into(),
1372 )
1373 }
1374
1375 #[cold]
1377 #[inline(never)]
1378 pub(crate) fn store_unsupported(message: impl Into<String>) -> Self {
1379 Self::new(ErrorClass::Unsupported, ErrorOrigin::Store, message.into())
1380 }
1381
1382 pub(crate) fn migration_label_empty(label: &str) -> Self {
1384 Self::store_unsupported(format!("{label} cannot be empty"))
1385 }
1386
1387 pub(crate) fn migration_step_row_ops_required(name: &str) -> Self {
1389 Self::store_unsupported(format!(
1390 "migration step '{name}' must include at least one row op",
1391 ))
1392 }
1393
1394 pub(crate) fn migration_plan_version_required(id: &str) -> Self {
1396 Self::store_unsupported(format!("migration plan '{id}' version must be > 0"))
1397 }
1398
1399 pub(crate) fn migration_plan_steps_required(id: &str) -> Self {
1401 Self::store_unsupported(format!(
1402 "migration plan '{id}' must include at least one step",
1403 ))
1404 }
1405
1406 pub(crate) fn migration_cursor_out_of_bounds(
1408 id: &str,
1409 version: u64,
1410 next_step: usize,
1411 total_steps: usize,
1412 ) -> Self {
1413 Self::store_unsupported(format!(
1414 "migration '{id}@{version}' cursor out of bounds: next_step={next_step} total_steps={total_steps}",
1415 ))
1416 }
1417
1418 pub(crate) fn migration_execution_requires_max_steps(id: &str) -> Self {
1420 Self::store_unsupported(format!("migration '{id}' execution requires max_steps > 0"))
1421 }
1422
1423 pub(crate) fn migration_in_progress_conflict(
1425 requested_id: &str,
1426 requested_version: u64,
1427 active_id: &str,
1428 active_version: u64,
1429 ) -> Self {
1430 Self::store_unsupported(format!(
1431 "migration '{requested_id}@{requested_version}' cannot execute while migration '{active_id}@{active_version}' is in progress",
1432 ))
1433 }
1434
1435 pub(crate) fn unsupported_entity_tag_in_data_store(
1437 entity_tag: crate::types::EntityTag,
1438 ) -> Self {
1439 Self::store_unsupported(format!(
1440 "unsupported entity tag in data store: '{}'",
1441 entity_tag.value()
1442 ))
1443 }
1444
1445 pub(crate) fn configured_commit_memory_id_mismatch(
1447 configured_id: u8,
1448 registered_id: u8,
1449 ) -> Self {
1450 Self::store_unsupported(format!(
1451 "configured commit memory id {configured_id} does not match existing commit marker id {registered_id}",
1452 ))
1453 }
1454
1455 pub(crate) fn commit_memory_id_already_registered(memory_id: u8, label: &str) -> Self {
1457 Self::store_unsupported(format!(
1458 "configured commit memory id {memory_id} is already registered as '{label}'",
1459 ))
1460 }
1461
1462 pub(crate) fn commit_memory_id_outside_reserved_ranges(memory_id: u8) -> Self {
1464 Self::store_unsupported(format!(
1465 "configured commit memory id {memory_id} is outside reserved ranges",
1466 ))
1467 }
1468
1469 pub(crate) fn commit_memory_id_registration_failed(err: impl fmt::Display) -> Self {
1471 Self::store_internal(format!("commit memory id registration failed: {err}"))
1472 }
1473
1474 pub(crate) fn index_unsupported(message: impl Into<String>) -> Self {
1476 Self::new(ErrorClass::Unsupported, ErrorOrigin::Index, message.into())
1477 }
1478
1479 pub(crate) fn index_component_exceeds_max_size(
1481 key_item: impl fmt::Display,
1482 len: usize,
1483 max_component_size: usize,
1484 ) -> Self {
1485 Self::index_unsupported(format!(
1486 "index component exceeds max size: key item '{key_item}' -> {len} bytes (limit {max_component_size})",
1487 ))
1488 }
1489
1490 pub(crate) fn index_entry_exceeds_max_keys(
1492 entity_path: &str,
1493 fields: &str,
1494 keys: usize,
1495 ) -> Self {
1496 Self::index_unsupported(format!(
1497 "index entry exceeds max keys: {entity_path} ({fields}) -> {keys} keys",
1498 ))
1499 }
1500
1501 #[cfg(test)]
1503 pub(crate) fn index_entry_duplicate_keys_unexpected(entity_path: &str, fields: &str) -> Self {
1504 Self::index_invariant(format!(
1505 "index entry unexpectedly contains duplicate keys: {entity_path} ({fields})",
1506 ))
1507 }
1508
1509 pub(crate) fn index_entry_key_encoding_failed(
1511 entity_path: &str,
1512 fields: &str,
1513 err: impl fmt::Display,
1514 ) -> Self {
1515 Self::index_unsupported(format!(
1516 "index entry key encoding failed: {entity_path} ({fields}) -> {err}",
1517 ))
1518 }
1519
1520 pub(crate) fn serialize_unsupported(message: impl Into<String>) -> Self {
1522 Self::new(
1523 ErrorClass::Unsupported,
1524 ErrorOrigin::Serialize,
1525 message.into(),
1526 )
1527 }
1528
1529 pub(crate) fn cursor_unsupported(message: impl Into<String>) -> Self {
1531 Self::new(ErrorClass::Unsupported, ErrorOrigin::Cursor, message.into())
1532 }
1533
1534 pub(crate) fn serialize_incompatible_persisted_format(message: impl Into<String>) -> Self {
1536 Self::new(
1537 ErrorClass::IncompatiblePersistedFormat,
1538 ErrorOrigin::Serialize,
1539 message.into(),
1540 )
1541 }
1542
1543 #[cfg(feature = "sql")]
1546 pub(crate) fn query_unsupported_sql_feature(feature: &'static str) -> Self {
1547 let message = format!(
1548 "SQL query is not executable in this release: unsupported SQL feature: {feature}"
1549 );
1550
1551 Self {
1552 class: ErrorClass::Unsupported,
1553 origin: ErrorOrigin::Query,
1554 message,
1555 detail: Some(ErrorDetail::Query(
1556 QueryErrorDetail::UnsupportedSqlFeature { feature },
1557 )),
1558 }
1559 }
1560
1561 pub fn store_not_found(key: impl Into<String>) -> Self {
1562 let key = key.into();
1563
1564 Self {
1565 class: ErrorClass::NotFound,
1566 origin: ErrorOrigin::Store,
1567 message: format!("data key not found: {key}"),
1568 detail: Some(ErrorDetail::Store(StoreError::NotFound { key })),
1569 }
1570 }
1571
1572 pub fn unsupported_entity_path(path: impl Into<String>) -> Self {
1574 let path = path.into();
1575
1576 Self::new(
1577 ErrorClass::Unsupported,
1578 ErrorOrigin::Store,
1579 format!("unsupported entity path: '{path}'"),
1580 )
1581 }
1582
1583 #[must_use]
1584 pub const fn is_not_found(&self) -> bool {
1585 matches!(
1586 self.detail,
1587 Some(ErrorDetail::Store(StoreError::NotFound { .. }))
1588 )
1589 }
1590
1591 #[must_use]
1592 pub fn display_with_class(&self) -> String {
1593 format!("{}:{}: {}", self.origin, self.class, self.message)
1594 }
1595
1596 #[cold]
1598 #[inline(never)]
1599 pub(crate) fn index_plan_corruption(origin: ErrorOrigin, message: impl Into<String>) -> Self {
1600 let message = message.into();
1601 Self::new(
1602 ErrorClass::Corruption,
1603 origin,
1604 format!("corruption detected ({origin}): {message}"),
1605 )
1606 }
1607
1608 #[cold]
1610 #[inline(never)]
1611 pub(crate) fn index_plan_index_corruption(message: impl Into<String>) -> Self {
1612 Self::index_plan_corruption(ErrorOrigin::Index, message)
1613 }
1614
1615 #[cold]
1617 #[inline(never)]
1618 pub(crate) fn index_plan_store_corruption(message: impl Into<String>) -> Self {
1619 Self::index_plan_corruption(ErrorOrigin::Store, message)
1620 }
1621
1622 #[cold]
1624 #[inline(never)]
1625 pub(crate) fn index_plan_serialize_corruption(message: impl Into<String>) -> Self {
1626 Self::index_plan_corruption(ErrorOrigin::Serialize, message)
1627 }
1628
1629 #[cfg(test)]
1631 pub(crate) fn index_plan_invariant(origin: ErrorOrigin, message: impl Into<String>) -> Self {
1632 let message = message.into();
1633 Self::new(
1634 ErrorClass::InvariantViolation,
1635 origin,
1636 format!("invariant violation detected ({origin}): {message}"),
1637 )
1638 }
1639
1640 #[cfg(test)]
1642 pub(crate) fn index_plan_store_invariant(message: impl Into<String>) -> Self {
1643 Self::index_plan_invariant(ErrorOrigin::Store, message)
1644 }
1645
1646 pub(crate) fn index_violation(path: &str, index_fields: &[&str]) -> Self {
1648 Self::new(
1649 ErrorClass::Conflict,
1650 ErrorOrigin::Index,
1651 format!(
1652 "index constraint violation: {path} ({})",
1653 index_fields.join(", ")
1654 ),
1655 )
1656 }
1657}
1658
1659#[derive(Debug, ThisError)]
1667pub enum ErrorDetail {
1668 #[error("{0}")]
1669 Store(StoreError),
1670 #[error("{0}")]
1671 Query(QueryErrorDetail),
1672 }
1679
1680#[derive(Debug, ThisError)]
1688pub enum StoreError {
1689 #[error("key not found: {key}")]
1690 NotFound { key: String },
1691
1692 #[error("store corruption: {message}")]
1693 Corrupt { message: String },
1694
1695 #[error("store invariant violation: {message}")]
1696 InvariantViolation { message: String },
1697}
1698
1699#[derive(Debug, ThisError)]
1706pub enum QueryErrorDetail {
1707 #[error("unsupported SQL feature: {feature}")]
1708 UnsupportedSqlFeature { feature: &'static str },
1709}
1710
1711#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1718pub enum ErrorClass {
1719 Corruption,
1720 IncompatiblePersistedFormat,
1721 NotFound,
1722 Internal,
1723 Conflict,
1724 Unsupported,
1725 InvariantViolation,
1726}
1727
1728impl fmt::Display for ErrorClass {
1729 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1730 let label = match self {
1731 Self::Corruption => "corruption",
1732 Self::IncompatiblePersistedFormat => "incompatible_persisted_format",
1733 Self::NotFound => "not_found",
1734 Self::Internal => "internal",
1735 Self::Conflict => "conflict",
1736 Self::Unsupported => "unsupported",
1737 Self::InvariantViolation => "invariant_violation",
1738 };
1739 write!(f, "{label}")
1740 }
1741}
1742
1743#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1750pub enum ErrorOrigin {
1751 Serialize,
1752 Store,
1753 Index,
1754 Identity,
1755 Query,
1756 Planner,
1757 Cursor,
1758 Recovery,
1759 Response,
1760 Executor,
1761 Interface,
1762}
1763
1764impl fmt::Display for ErrorOrigin {
1765 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1766 let label = match self {
1767 Self::Serialize => "serialize",
1768 Self::Store => "store",
1769 Self::Index => "index",
1770 Self::Identity => "identity",
1771 Self::Query => "query",
1772 Self::Planner => "planner",
1773 Self::Cursor => "cursor",
1774 Self::Recovery => "recovery",
1775 Self::Response => "response",
1776 Self::Executor => "executor",
1777 Self::Interface => "interface",
1778 };
1779 write!(f, "{label}")
1780 }
1781}