error.rs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /// The error types.
  2. #[derive(thiserror::Error, Debug)]
  3. pub enum Error {
  4. /// The extract archive error.
  5. #[error("Extract Error: {0}")]
  6. Extract(String),
  7. /// The Command (spawn process) error.
  8. #[error("Command Error: {0}")]
  9. Command(String),
  10. /// The path operation error.
  11. #[error("Path Error: {0}")]
  12. Path(String),
  13. /// Error showing the dialog.
  14. #[error("Dialog Error: {0}")]
  15. Dialog(String),
  16. /// The dialog operation was cancelled by the user.
  17. #[error("user cancelled the dialog")]
  18. DialogCancelled,
  19. /// CLI config not set.
  20. #[error("CLI configuration not set on tauri.conf.json")]
  21. CliNotConfigured,
  22. /// The HTTP response error.
  23. #[error("HTTP Response Error: {0}")]
  24. Response(attohttpc::StatusCode),
  25. /// The network error.
  26. #[error("Network Error: {0}")]
  27. Network(#[from] attohttpc::Error),
  28. /// HTTP method error.
  29. #[error("{0}")]
  30. HttpMethod(#[from] http::method::InvalidMethod),
  31. /// Invalid HTTO header.
  32. #[error("{0}")]
  33. HttpHeader(#[from] attohttpc::header::InvalidHeaderName),
  34. /// Semver error.
  35. #[error("{0}")]
  36. Semver(#[from] semver::SemVerError),
  37. /// JSON error.
  38. #[error("{0}")]
  39. Json(#[from] serde_json::Error),
  40. /// IO error.
  41. #[error("{0}")]
  42. Io(#[from] std::io::Error),
  43. /// ZIP error.
  44. #[error("{0}")]
  45. Zip(#[from] zip::result::ZipError),
  46. /// Notification error.
  47. #[error("{0}")]
  48. Notification(#[from] notify_rust::error::Error),
  49. /// failed to detect the current platform.
  50. #[error("failed to detect platform: {0}")]
  51. FailedToDetectPlatform(String),
  52. /// CLI argument parsing error.
  53. #[cfg(feature = "cli")]
  54. #[error("failed to parse CLI arguments: {0}")]
  55. ParseCliArguments(#[from] clap::Error),
  56. /// Shortcut error.
  57. #[cfg(feature = "global-shortcut")]
  58. #[error("shortcut error: {0}")]
  59. Shortcut(#[from] tauri_hotkey::Error),
  60. }
  61. impl From<attohttpc::StatusCode> for Error {
  62. fn from(error: attohttpc::StatusCode) -> Self {
  63. Self::Response(error)
  64. }
  65. }