error.rs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. use sled_overlay::sled;
  19. pub type Result<T> = std::result::Result<T, Error>;
  20. #[repr(u8)]
  21. #[derive(Debug, Copy, Clone, thiserror::Error)]
  22. pub enum Error {
  23. #[error("Invalid scene path")]
  24. InvalidScenePath = 1,
  25. #[error("Node not found")]
  26. NodeNotFound = 2,
  27. #[error("Child node not found")]
  28. ChildNodeNotFound = 3,
  29. #[error("Parent node not found")]
  30. ParentNodeNotFound = 4,
  31. #[error("Property already exists")]
  32. PropertyAlreadyExists = 5,
  33. #[error("Property not found")]
  34. PropertyNotFound = 6,
  35. #[error("Property has wrong type")]
  36. PropertyWrongType = 7,
  37. #[error("Property value has the wrong length")]
  38. PropertyWrongLen = 9,
  39. #[error("Property index is wrong")]
  40. PropertyWrongIndex = 10,
  41. #[error("Property out of range")]
  42. PropertyOutOfRange = 11,
  43. #[error("Property null not allowed")]
  44. PropertyNullNotAllowed = 12,
  45. #[error("Property S-exprs not allowed")]
  46. PropertySExprNotAllowed = 13,
  47. #[error("Property array is bounded length")]
  48. PropertyIsBounded = 14,
  49. #[error("Property enum item is invalid")]
  50. PropertyWrongEnumItem = 15,
  51. #[error("Signal already exists")]
  52. SignalAlreadyExists = 16,
  53. #[error("Signal not found")]
  54. SignalNotFound = 17,
  55. #[error("Slot not found")]
  56. SlotNotFound = 18,
  57. #[error("Signal already exists")]
  58. MethodAlreadyExists = 19,
  59. #[error("Method not found")]
  60. MethodNotFound = 20,
  61. #[error("Nodes are not linked")]
  62. NodesAreLinked = 21,
  63. #[error("Nodes are not linked")]
  64. NodesNotLinked = 22,
  65. #[error("Nodes are the same")]
  66. NodesAreSame = 37,
  67. #[error("Node has parents")]
  68. NodeHasParents = 23,
  69. #[error("Node has children")]
  70. NodeHasChildren = 24,
  71. #[error("Node has a parent with this name")]
  72. NodeParentNameConflict = 25,
  73. #[error("Node has a child with this name")]
  74. NodeChildNameConflict = 26,
  75. #[error("Node has a sibling with this name")]
  76. NodeSiblingNameConflict = 27,
  77. #[error("S-expr global not found")]
  78. SExprGlobalNotFound = 32,
  79. #[error("Publisher was destroyed")]
  80. PublisherDestroyed = 34,
  81. #[error("Channel closed")]
  82. ChannelClosed = 36,
  83. #[error("Unexpected token found")]
  84. UnexpectedToken = 38,
  85. #[error("Sled database error")]
  86. SledDbErr = 39,
  87. #[error("Service failed")]
  88. ServiceFailed = 40,
  89. #[error("Duplicate texture ID")]
  90. GfxDuplicateTextureID = 41,
  91. #[error("Unknown texture ID")]
  92. GfxUnknownTextureID = 42,
  93. #[error("Duplicate buffer ID")]
  94. GfxDuplicateBufferID = 43,
  95. #[error("Unknown buffer ID")]
  96. GfxUnknownBufferID = 44,
  97. #[error("Duplicate anim ID")]
  98. GfxDuplicateAnimID = 45,
  99. #[error("Unknown anim ID")]
  100. GfxUnknownAnimID = 46,
  101. }
  102. impl From<sled::Error> for Error {
  103. fn from(_: sled::Error) -> Error {
  104. Error::SledDbErr
  105. }
  106. }