error.rs 3.6 KB

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