1#[cfg(all(backtrace, debug_assertions))]
2use std::sync::Arc;
3
4#[derive(Debug, Copy, Clone)]
5pub enum DataSetError {
6 ValueDoesNotMatchSchema,
7 PathParentIsNull,
8 PathDynamicArrayEntryDoesNotExist,
9 UnexpectedEnumSymbol,
10 DuplicateAssetId,
11 DuplicateEntryKey,
12 EntryKeyNotFound,
13 AssetNotFound,
14 ImportDataNotFound,
15 SingleObjectDoesNotMatchSchema,
16 LocationCycleDetected,
17 LocationParentNotFound,
18 SchemaNotFound,
19 InvalidSchema,
20 UuidParseError,
21 StorageFormatError,
22 NewLocationIsChildOfCurrentAsset,
23 UnknownPathNamespace,
24 InvalidPath,
25
26 DataTaken,
28}
29
30#[derive(Clone)]
33pub struct DataSetErrorWithBacktrace {
34 pub error: DataSetError,
35 #[cfg(all(backtrace, debug_assertions))]
36 pub backtrace: Arc<backtrace::Backtrace>,
37}
38
39impl From<DataSetError> for DataSetErrorWithBacktrace {
40 fn from(error: DataSetError) -> Self {
41 DataSetErrorWithBacktrace {
42 error,
43 #[cfg(all(backtrace, debug_assertions))]
44 backtrace: Arc::new(backtrace::Backtrace::new()),
45 }
46 }
47}
48
49impl std::fmt::Debug for DataSetErrorWithBacktrace {
50 #[cfg(not(all(backtrace, debug_assertions)))]
51 fn fmt(
52 &self,
53 f: &mut std::fmt::Formatter<'_>,
54 ) -> std::fmt::Result {
55 write!(f, "{:?}", self.error)
56 }
57
58 #[cfg(all(backtrace, debug_assertions))]
59 fn fmt(
60 &self,
61 f: &mut std::fmt::Formatter<'_>,
62 ) -> std::fmt::Result {
63 write!(f, "{:?}:\n{:?}", self.error, *self.backtrace)
64 }
65}
66
67pub type DataSetResult<T> = Result<T, DataSetErrorWithBacktrace>;