error.rs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use std::{io, num, path};
  5. use thiserror::Error as DeriveError;
  6. /// Errors returned by the bundler.
  7. #[derive(Debug, DeriveError)]
  8. #[non_exhaustive]
  9. pub enum Error {
  10. /// Bundler error.
  11. #[error("{0}")]
  12. BundlerError(#[from] anyhow::Error),
  13. /// Failed to use glob pattern.
  14. #[error("`{0}`")]
  15. GlobError(#[from] glob::GlobError),
  16. /// Invalid glob pattern.
  17. #[error("`{0}`")]
  18. GlobPatternError(#[from] glob::PatternError),
  19. /// I/O error.
  20. #[error("`{0}`")]
  21. IoError(#[from] io::Error),
  22. /// Image error.
  23. #[error("`{0}`")]
  24. ImageError(#[from] image::ImageError),
  25. /// TOML error.
  26. #[error("`{0}`")]
  27. TomlError(#[from] toml::de::Error),
  28. /// Error walking directory.
  29. #[error("`{0}`")]
  30. WalkdirError(#[from] walkdir::Error),
  31. /// Strip prefix error.
  32. #[error("`{0}`")]
  33. StripError(#[from] path::StripPrefixError),
  34. /// Number parse error.
  35. #[error("`{0}`")]
  36. ConvertError(#[from] num::TryFromIntError),
  37. /// Zip error.
  38. #[error("`{0}`")]
  39. ZipError(#[from] zip::result::ZipError),
  40. /// Hex error.
  41. #[cfg(target_os = "windows")]
  42. #[error("`{0}`")]
  43. HexError(#[from] hex::FromHexError),
  44. /// Handlebars template error.
  45. #[error("`{0}`")]
  46. HandleBarsError(#[from] handlebars::RenderError),
  47. /// JSON error.
  48. #[error("`{0}`")]
  49. JsonError(#[from] serde_json::error::Error),
  50. /// Regex error.
  51. #[cfg(any(target_os = "macos", windows))]
  52. #[error("`{0}`")]
  53. RegexError(#[from] regex::Error),
  54. /// Failed to perform HTTP request.
  55. #[cfg(windows)]
  56. #[error("`{0}`")]
  57. HttpError(#[from] attohttpc::Error),
  58. /// Failed to validate downloaded file hash.
  59. #[error("hash mismatch of downloaded file")]
  60. HashError,
  61. /// Unsupported architecture.
  62. #[error("Architecture Error: `{0}`")]
  63. ArchError(String),
  64. /// Couldn't find icons.
  65. #[error("Could not find Icon paths. Please make sure they exist in the tauri config JSON file")]
  66. IconPathError,
  67. /// Error on path util operation.
  68. #[error("Path Error:`{0}`")]
  69. PathUtilError(String),
  70. /// Error on shell script.
  71. #[error("Shell Scripting Error:`{0}`")]
  72. ShellScriptError(String),
  73. /// Generic error.
  74. #[error("`{0}`")]
  75. GenericError(String),
  76. /// No bundled project found for the updater.
  77. #[error("Unable to find a bundled project for the updater")]
  78. UnableToFindProject,
  79. /// String is not UTF-8.
  80. #[error("string is not UTF-8")]
  81. Utf8(#[from] std::str::Utf8Error),
  82. /// Windows SignTool not found.
  83. #[error("SignTool not found")]
  84. SignToolNotFound,
  85. /// Failed to open Windows registry.
  86. #[error("failed to open registry {0}")]
  87. OpenRegistry(String),
  88. /// Failed to get registry value.
  89. #[error("failed to get {0} value on registry")]
  90. GetRegistryValue(String),
  91. /// Unsupported OS bitness.
  92. #[error("unsupported OS bitness")]
  93. UnsupportedBitness,
  94. /// Failed to sign application.
  95. #[error("failed to sign app: {0}")]
  96. Sign(String),
  97. /// time error.
  98. #[cfg(target_os = "macos")]
  99. #[error("`{0}`")]
  100. TimeError(#[from] time::error::Error),
  101. }
  102. /// Convenient type alias of Result type.
  103. pub type Result<T> = anyhow::Result<T, Error>;