tauri_bundler/
error.rs

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