error.rs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. /// The error types.
  5. #[derive(thiserror::Error, Debug)]
  6. pub enum Error {
  7. /// Command error.
  8. #[error("Command Error: {0}")]
  9. Command(String),
  10. /// The extract archive error.
  11. #[error("Extract Error: {0}")]
  12. Extract(String),
  13. /// The path operation error.
  14. #[error("Path Error: {0}")]
  15. Path(String),
  16. /// The path StripPrefixError error.
  17. #[error("Path Error: {0}")]
  18. PathPrefix(#[from] std::path::StripPrefixError),
  19. /// Error showing the dialog.
  20. #[error("Dialog Error: {0}")]
  21. Dialog(String),
  22. /// The dialog operation was cancelled by the user.
  23. #[error("user cancelled the dialog")]
  24. DialogCancelled,
  25. /// The network error.
  26. #[error("Network Error: {0}")]
  27. Network(#[from] reqwest::Error),
  28. /// HTTP method error.
  29. #[error("{0}")]
  30. HttpMethod(#[from] http::method::InvalidMethod),
  31. /// Invalid HTTO header.
  32. #[error("{0}")]
  33. HttpHeader(#[from] reqwest::header::InvalidHeaderName),
  34. /// Failed to serialize header value as string.
  35. #[error("failed to convert response header value to string")]
  36. HttpHeaderToString(#[from] reqwest::header::ToStrError),
  37. /// HTTP form to must be an object.
  38. #[error("http form must be an object")]
  39. InvalidHttpForm,
  40. /// Semver error.
  41. #[error("{0}")]
  42. Semver(#[from] semver::SemVerError),
  43. /// JSON error.
  44. #[error("{0}")]
  45. Json(#[from] serde_json::Error),
  46. /// IO error.
  47. #[error("{0}")]
  48. Io(#[from] std::io::Error),
  49. /// Ignore error.
  50. #[error("failed to walkdir: {0}")]
  51. Ignore(#[from] ignore::Error),
  52. /// ZIP error.
  53. #[error("{0}")]
  54. Zip(#[from] zip::result::ZipError),
  55. /// Notification error.
  56. #[cfg(notification_all)]
  57. #[error("{0}")]
  58. Notification(#[from] notify_rust::error::Error),
  59. /// failed to detect the current platform.
  60. #[error("failed to detect platform: {0}")]
  61. FailedToDetectPlatform(String),
  62. /// CLI argument parsing error.
  63. #[cfg(feature = "cli")]
  64. #[error("failed to parse CLI arguments: {0}")]
  65. ParseCliArguments(#[from] clap::Error),
  66. /// Shortcut error.
  67. #[cfg(global_shortcut_all)]
  68. #[error("shortcut error: {0}")]
  69. Shortcut(#[from] tauri_hotkey::Error),
  70. /// Shell error.
  71. #[error("shell error: {0}")]
  72. Shell(String),
  73. }