error.rs
1 /* This file is part of DarkFi (https://dark.fi) 2 * 3 * Copyright (C) 2020-2025 Dyne.org foundation 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Affero General Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 */ 18 19 use sled_overlay::sled; 20 21 pub type Result<T> = std::result::Result<T, Error>; 22 23 #[repr(u8)] 24 #[derive(Debug, Copy, Clone, thiserror::Error)] 25 pub enum Error { 26 #[error("Invalid scene path")] 27 InvalidScenePath = 1, 28 29 #[error("Node not found")] 30 NodeNotFound = 2, 31 32 #[error("Child node not found")] 33 ChildNodeNotFound = 3, 34 35 #[error("Parent node not found")] 36 ParentNodeNotFound = 4, 37 38 #[error("Property already exists")] 39 PropertyAlreadyExists = 5, 40 41 #[error("Property not found")] 42 PropertyNotFound = 6, 43 44 #[error("Property has wrong type")] 45 PropertyWrongType = 7, 46 47 #[error("Property value has the wrong length")] 48 PropertyWrongLen = 9, 49 50 #[error("Property index is wrong")] 51 PropertyWrongIndex = 10, 52 53 #[error("Property out of range")] 54 PropertyOutOfRange = 11, 55 56 #[error("Property null not allowed")] 57 PropertyNullNotAllowed = 12, 58 59 #[error("Property S-exprs not allowed")] 60 PropertySExprNotAllowed = 13, 61 62 #[error("Property array is bounded length")] 63 PropertyIsBounded = 14, 64 65 #[error("Property enum item is invalid")] 66 PropertyWrongEnumItem = 15, 67 68 #[error("Signal already exists")] 69 SignalAlreadyExists = 16, 70 71 #[error("Signal not found")] 72 SignalNotFound = 17, 73 74 #[error("Slot not found")] 75 SlotNotFound = 18, 76 77 #[error("Signal already exists")] 78 MethodAlreadyExists = 19, 79 80 #[error("Method not found")] 81 MethodNotFound = 20, 82 83 #[error("Nodes are not linked")] 84 NodesAreLinked = 21, 85 86 #[error("Nodes are not linked")] 87 NodesNotLinked = 22, 88 89 #[error("Nodes are the same")] 90 NodesAreSame = 37, 91 92 #[error("Node has parents")] 93 NodeHasParents = 23, 94 95 #[error("Node has children")] 96 NodeHasChildren = 24, 97 98 #[error("Node has a parent with this name")] 99 NodeParentNameConflict = 25, 100 101 #[error("Node has a child with this name")] 102 NodeChildNameConflict = 26, 103 104 #[error("Node has a sibling with this name")] 105 NodeSiblingNameConflict = 27, 106 107 #[error("S-expr global not found")] 108 SExprGlobalNotFound = 32, 109 110 #[error("Publisher was destroyed")] 111 PublisherDestroyed = 34, 112 113 #[error("Channel closed")] 114 ChannelClosed = 36, 115 116 #[error("Unexpected token found")] 117 UnexpectedToken = 38, 118 119 #[error("Sled database error")] 120 SledDbErr = 39, 121 122 #[error("Service failed")] 123 ServiceFailed = 40, 124 125 #[error("Duplicate texture ID")] 126 GfxDuplicateTextureID = 41, 127 128 #[error("Unknown texture ID")] 129 GfxUnknownTextureID = 42, 130 131 #[error("Duplicate buffer ID")] 132 GfxDuplicateBufferID = 43, 133 134 #[error("Unknown buffer ID")] 135 GfxUnknownBufferID = 44, 136 137 #[error("Duplicate anim ID")] 138 GfxDuplicateAnimID = 45, 139 140 #[error("Unknown anim ID")] 141 GfxUnknownAnimID = 46, 142 } 143 144 impl From<sled::Error> for Error { 145 fn from(_: sled::Error) -> Error { 146 Error::SledDbErr 147 } 148 }