error.rs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use thiserror::Error;
  5. /// All errors that can occur while running the updater.
  6. #[derive(Debug, Error)]
  7. #[non_exhaustive]
  8. pub enum Error {
  9. /// IO Errors.
  10. #[error("`{0}`")]
  11. Io(#[from] std::io::Error),
  12. /// Semver Errors.
  13. #[error("Unable to compare version: {0}")]
  14. Semver(#[from] semver::Error),
  15. /// JSON (Serde) Errors.
  16. #[error("JSON error: {0}")]
  17. SerdeJson(#[from] serde_json::Error),
  18. /// Minisign is used for signature validation.
  19. #[error("Verify signature error: {0}")]
  20. Minisign(#[from] minisign_verify::Error),
  21. /// Error with Minisign base64 decoding.
  22. #[error("Signature decoding error: {0}")]
  23. Base64(#[from] base64::DecodeError),
  24. /// UTF8 Errors in signature.
  25. #[error("The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string.")]
  26. SignatureUtf8(String),
  27. /// Tauri utils, mainly extract and file move.
  28. #[error("Tauri API error: {0}")]
  29. TauriApi(#[from] crate::api::Error),
  30. /// Network error.
  31. #[error("Network error: {0}")]
  32. Network(String),
  33. /// Could not fetch a valid response from the server.
  34. #[error("Could not fetch a valid release JSON from the remote")]
  35. ReleaseNotFound,
  36. /// Error building updater.
  37. #[error("Unable to prepare the updater: {0}")]
  38. Builder(String),
  39. /// Error building updater.
  40. #[error("Unable to extract the new version: {0}")]
  41. Extract(String),
  42. /// Updater cannot be executed on this Linux package. Currently the updater is enabled only on AppImages.
  43. #[error("Cannot run updater on this Linux package. Currently only an AppImage can be updated.")]
  44. UnsupportedLinuxPackage,
  45. /// Operating system is not supported.
  46. #[error("unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
  47. UnsupportedOs,
  48. /// Unsupported app architecture.
  49. #[error(
  50. "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`."
  51. )]
  52. UnsupportedArch,
  53. /// The platform was not found on the updater JSON response.
  54. #[error("the platform `{0}` was not found on the response `platforms` object")]
  55. TargetNotFound(String),
  56. /// Triggered when there is NO error and the two versions are equals.
  57. /// On client side, it's important to catch this error.
  58. #[error("No updates available")]
  59. UpToDate,
  60. /// The updater responded with an invalid signature type.
  61. #[error("the updater response field `{0}` type is invalid, expected {1} but found {2}")]
  62. InvalidResponseType(&'static str, &'static str, serde_json::Value),
  63. /// HTTP error.
  64. #[error(transparent)]
  65. Http(#[from] http::Error),
  66. /// Temp dir is not on same mount mount. This prevents our updater to rename the AppImage to a temp file.
  67. #[cfg(target_os = "linux")]
  68. #[error("temp directory is not on the same mount point as the AppImage")]
  69. TempDirNotOnSameMountPoint,
  70. }
  71. pub type Result<T = ()> = std::result::Result<T, Error>;