error.rs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2023 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 serde_json::Value;
  19. // use darkfi::rpc::jsonrpc::{ErrorCode::ServerError, JsonError, JsonResult};
  20. #[derive(Debug, thiserror::Error)]
  21. pub enum DaoError {
  22. // #[error("No Proposals found")]
  23. // NoProposals,
  24. // #[error("No DAO params found")]
  25. // DaoNotConfigured,
  26. // #[error("State transition failed: '{0}'")]
  27. // StateTransitionFailed(String),
  28. // #[error("Wallet does not exist")]
  29. // NoWalletFound,
  30. // #[error("State not found")]
  31. // StateNotFound,
  32. #[error("InternalError")]
  33. Darkfi(#[from] darkfi::error::Error),
  34. #[error("Verify proof failed: '{0}', '{0}'")]
  35. VerifyProofFailed(usize, String),
  36. }
  37. pub type DaoResult<T> = std::result::Result<T, DaoError>;
  38. // pub enum RpcError {
  39. // Vote = -32101,
  40. // Propose = -32102,
  41. // Exec = -32103,
  42. // Airdrop = -32104,
  43. // Mint = -32105,
  44. // Keygen = -32106,
  45. // Create = -32107,
  46. // Parse = -32108,
  47. // Balance = -32109,
  48. // }
  49. // fn to_tuple(e: RpcError) -> (i64, String) {
  50. // let msg = match e {
  51. // RpcError::Vote => "Failed to cast a Vote",
  52. // RpcError::Propose => "Failed to generate a Proposal",
  53. // RpcError::Airdrop => "Failed to transfer an airdrop",
  54. // RpcError::Keygen => "Failed to generate keypair",
  55. // RpcError::Create => "Failed to create DAO",
  56. // RpcError::Exec => "Failed to execute Proposal",
  57. // RpcError::Mint => "Failed to mint DAO treasury",
  58. // RpcError::Parse => "Generic parsing error",
  59. // RpcError::Balance => "Failed to get balance",
  60. // };
  61. // (e as i64, msg.to_string())
  62. // }
  63. // pub fn server_error(e: RpcError, id: Value) -> JsonResult {
  64. // let (code, msg) = to_tuple(e);
  65. // JsonError::new(ServerError(code), Some(msg), id).into()
  66. // }