error.rs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #[non_exhaustive]
  7. pub enum Error {
  8. /// Command error.
  9. #[error("Command Error: {0}")]
  10. Command(String),
  11. /// The extract archive error.
  12. #[error("Extract Error: {0}")]
  13. Extract(String),
  14. /// The path operation error.
  15. #[error("Path Error: {0}")]
  16. Path(String),
  17. /// The path StripPrefixError error.
  18. #[error("Path Error: {0}")]
  19. PathPrefix(#[from] std::path::StripPrefixError),
  20. /// Error showing the dialog.
  21. #[error("Dialog Error: {0}")]
  22. Dialog(String),
  23. /// The dialog operation was cancelled by the user.
  24. #[error("user cancelled the dialog")]
  25. DialogCancelled,
  26. /// The network error.
  27. #[cfg(not(feature = "reqwest-client"))]
  28. #[error("Network Error: {0}")]
  29. Network(#[from] attohttpc::Error),
  30. /// The network error.
  31. #[cfg(feature = "reqwest-client")]
  32. #[error("Network Error: {0}")]
  33. Network(#[from] reqwest::Error),
  34. /// HTTP request error. First parameter is the response status code, and the second is the response text.
  35. #[error("HTTP Error: status code {0} and response `{1}`")]
  36. Http(u16, String),
  37. /// HTTP method error.
  38. #[error("{0}")]
  39. HttpMethod(#[from] http::method::InvalidMethod),
  40. /// Invalid HTTP header value.
  41. #[cfg(feature = "reqwest-client")]
  42. #[error("{0}")]
  43. HttpHeaderValue(#[from] http::header::InvalidHeaderValue),
  44. /// Invalid HTTP header value.
  45. #[error("{0}")]
  46. HttpHeader(#[from] http::header::InvalidHeaderName),
  47. /// Failed to serialize header value as string.
  48. #[error("failed to convert response header value to string")]
  49. HttpHeaderToString(#[from] http::header::ToStrError),
  50. /// HTTP form to must be an object.
  51. #[error("http form must be an object")]
  52. InvalidHttpForm,
  53. /// Semver error.
  54. #[error("{0}")]
  55. Semver(#[from] semver::Error),
  56. /// JSON error.
  57. #[error("{0}")]
  58. Json(#[from] serde_json::Error),
  59. /// Bincode error.
  60. #[error("{0}")]
  61. Bincode(#[from] Box<bincode::ErrorKind>),
  62. /// IO error.
  63. #[error("{0}")]
  64. Io(#[from] std::io::Error),
  65. /// Ignore error.
  66. #[error("failed to walkdir: {0}")]
  67. Ignore(#[from] ignore::Error),
  68. /// ZIP error.
  69. #[error("{0}")]
  70. Zip(#[from] zip::result::ZipError),
  71. /// Notification error.
  72. #[cfg(notification_all)]
  73. #[error("{0}")]
  74. Notification(#[from] notify_rust::error::Error),
  75. /// failed to detect the current platform.
  76. #[error("failed to detect platform: {0}")]
  77. FailedToDetectPlatform(String),
  78. /// CLI argument parsing error.
  79. #[cfg(feature = "cli")]
  80. #[error("failed to parse CLI arguments: {0}")]
  81. ParseCliArguments(#[from] clap::Error),
  82. /// Shell error.
  83. #[error("shell error: {0}")]
  84. Shell(String),
  85. }