hit_data/errors/
hit_error.rs1use std::backtrace::Backtrace;
2use std::{clone::Clone, collections::HashMap};
3use serde::Serialize;
4use thiserror::*;
5
6use crate::IndexEntryProperty;
7
8#[derive(Error, Clone, Debug, PartialEq, Serialize)]
9pub enum HitError {
10 #[error("There is no model entry for id `{0}`")]
11 NoModelForId(String),
12 #[error("Property `{0}` does not exist")]
13 PropertyNotFound(String),
14 #[error("Model `{0}` does not exist")]
15 ModelDoesNotExist(String),
16 #[error("Invalid move destination")]
17 InvalidMoveDestination(),
18 #[error("Invalid data type")]
19 InvalidDataType(),
20 #[error("Invalid date format")]
21 InvalidDateFormat(),
22 #[error("Invalid reference: `{0}`")]
23 InvalidReference(String),
24 #[error("Invalid Reference in array")]
26 InvalidReferenceInArray(),
27 #[error("Invalid reference type")]
28 InvalidReferenceType(),
29 #[error("Invalid reference type in an array")]
30 InvalidReferenceTypeInArray(),
31 #[error("This field is required")]
32 Required(),
33 #[error("Model `{0}` is not allowed here")]
34 ModelNotAllowed(String),
35 #[error("ID not found: `{0}`, ref: `{1}`")]
36 IDNotFound(String, String),
37 #[error("Listener Not Found: `{0}`")]
38 ListenerNotFound(String),
39 #[error("VALIDATION ERROR: TODO THIS SHOULD NOT BE A HITERROR")]
40 ValidationError(),
41 #[error("No parent (this is the main object)")]
42 NoParent(),
43 #[error("Invalid parent ID: `{0}`")]
44 InvalidParentID(String),
45 #[error("ID already exists in this document: `{0}`")]
46 DuplicateID(String),
47 #[error("An object cannot be its own parent: `{0}`")]
48 CannotBeOwnParent(String),
49 #[error("The root object cannot be moved")]
50 CannotMoveRootObject(),
51 #[error("An object cannot be moved to its child object")]
52 CannotBeOwnChild(),
53 #[error("Only scalar values can be set")]
54 CanOnlySetScalarValues(),
55 #[error("Only scalar values can be set in an inserted object")]
56 CanOnlySetScalarValuesInInsertedObject(),
57 #[error("An object cannot be inserted into a property that is not a subobject array")]
58 CannotInsertObjectInThisDataType(),
59 #[error("A reference cannot be inserted into a property that is not a reference array")]
60 CannotInsertReferenceInThisDataType(),
61 #[error("This reference is already set in this property")]
62 CannotInsertReferenceTwice(),
63 #[error("This reference is not present in this property")]
64 ReferenceNotFound(),
65 #[error("A reference cannot be deleted from a property that is not a reference array")]
66 CannotRemoveReferenceFromThisDataType(),
67 #[error("An object cannot be delete from a property that is not an object array")]
68 CannotRemoveObjectFromThisDataType(),
69 #[error("This object cannot be deleted because there are references to it")]
70 CannotDeleteObjectWithReferences(HashMap<String, Vec<IndexEntryProperty>>),
71 #[error("The root object cannot be deleted")]
72 CannotDeleteRootObject(),
73 #[error("BeforeId is not present in this array: `{0}`")]
74 InvalidBeforeId(String),
75}