error.rs 563 B

123456789101112131415161718192021222324
  1. {{#if license_header}}
  2. {{ license_header }}
  3. {{/if}}
  4. use serde::{ser::Serializer, Serialize};
  5. pub type Result<T> = std::result::Result<T, Error>;
  6. #[derive(Debug, thiserror::Error)]
  7. pub enum Error {
  8. #[error(transparent)]
  9. Io(#[from] std::io::Error),
  10. #[cfg(mobile)]
  11. #[error(transparent)]
  12. PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
  13. }
  14. impl Serialize for Error {
  15. fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
  16. where
  17. S: Serializer,
  18. {
  19. serializer.serialize_str(self.to_string().as_ref())
  20. }
  21. }